fourierknots/fourier_syn.cpp
FourierKnot FourierKnot::operator+(const FourierKnot &fk) const {
  FourierKnot sum;

  int LocalSmaller = csin.size()<fk.csin.size();
  int N=min(csin.size(),fk.csin.size());
  int Nmax= max(fk.csin.size(),csin.size());

  for (int i=0;i<N;++i) {
    sum.csin.push_back(csin[i]+fk.csin[i]);
    sum.ccos.push_back(ccos[i]+fk.ccos[i]);
  }

  if (LocalSmaller)
    for (int i=N;i<Nmax;++i) {
      sum.csin.push_back(fk.csin[i]);
      sum.ccos.push_back(fk.ccos[i]);
    }
  else
    for (int i=N;i<Nmax;++i) {
      sum.csin.push_back(csin[i]);
      sum.ccos.push_back(ccos[i]);
    }

  sum.c0 = c0 + fk.c0;

  return sum;
}
/*!
  Sum of two FourierKnots. The summed FourierKnot's can have
  different sized coefficient vectors.
*/
Sum of two FourierKnots. The summed FourierKnot's can have
different sized coefficient vectors.
Sum of two FourierKnots . The summed FourierKnot ' s can have different sized coefficient vectors .
FourierKnot FourierKnot::operator+(const FourierKnot &fk) const {
  FourierKnot sum;
  int LocalSmaller = csin.size()<fk.csin.size();
  int N=min(csin.size(),fk.csin.size());
  int Nmax= max(fk.csin.size(),csin.size());
  for (int i=0;i<N;++i) {
    sum.csin.push_back(csin[i]+fk.csin[i]);
    sum.ccos.push_back(ccos[i]+fk.ccos[i]);
  }
  if (LocalSmaller)
    for (int i=N;i<Nmax;++i) {
      sum.csin.push_back(fk.csin[i]);
      sum.ccos.push_back(fk.ccos[i]);
    }
  else
    for (int i=N;i<Nmax;++i) {
      sum.csin.push_back(csin[i]);
      sum.ccos.push_back(ccos[i]);
    }
  sum.c0 = c0 + fk.c0;
  return sum;
}
FourierKnot FourierKnot :: operator + ( const FourierKnot & fk ) const { FourierKnot sum ; int LocalSmaller = csin . size ( ) < fk . csin . size ( ) ; int N = min ( csin . size ( ) , fk . csin . size ( ) ) ; int Nmax = max ( fk . csin . size ( ) , csin . size ( ) ) ; for ( int i = 0 ; i < N ; ++ i ) { sum . csin . push_back ( csin [ i ] + fk . csin [ i ] ) ; sum . ccos . push_back ( ccos [ i ] + fk . ccos [ i ] ) ; } if ( LocalSmaller ) for ( int i = N ; i < Nmax ; ++ i ) { sum . csin . push_back ( fk . csin [ i ] ) ; sum . ccos . push_back ( fk . ccos [ i ] ) ; } else for ( int i = N ; i < Nmax ; ++ i ) { sum . csin . push_back ( csin [ i ] ) ; sum . ccos . push_back ( ccos [ i ] ) ; } sum . c0 = c0 + fk . c0 ; return sum ; }
Sum of two FourierKnots.
Sum of two FourierKnots .