inventor/utils.cpp
void writhe_frame_normals(Tube<Vector3>* t, Vector3* Normals) {

  int Nloc = t->nodes();
  Vector3 e_ij, down_dir, tan;

  for (int i=0;i<Nloc;i++) {

    tan = (*t)[i].getTangent();

    vector<Biarc<Vector3> >::iterator bi_tmp, b_i = t->begin()+i;
    vector<Biarc<Vector3> >::iterator b_j = b_i + 1;
    if (b_j == t->end()) b_j = t->begin();

    down_dir = tan;
    while (b_j!=b_i) {
      e_ij = (b_j->getPoint()-b_i->getPoint());
      e_ij.normalize();
      down_dir += e_ij;
      // tmp.append(e_ij,Vector3(0,0,0));
      b_j = b_j + 1;
      if (b_j == t->end()) b_j = t->begin();
    }
    down_dir += -tan;

    down_dir/= (float)(Nloc+1);
    down_dir = down_dir - down_dir.dot(tan)*tan;
    down_dir.normalize();

    Normals[i] = down_dir;

  }
}
/*
 *  See ~/papers/Dennis_Hannay_-_Calugareanu_final.pdf
 *  Where we "approximate" the bisecting radial chord direction
 *  simply by summing the points on the chords C_s = (a(s) - a(s')/|a(s)-a(s')|
 *  where s' runs from s around the knot back to s. where at the endpoints we
 *  have +tangent, -tangent. The sum of these vectors divided by the number of
 *  nodes in the curve orthogonalized w.r.t the tangent gives us the next normal vector.
 *  This should mimick the fact that the "center of gravity" lies on the correct
 *  radial chord and that it corresponds to the surface area to the left and right
 *  of our bisecting chord.
 */
See ~/papers/Dennis_Hannay_-_Calugareanu_final.pdf
Where we "approximate" the bisecting radial chord direction
simply by summing the points on the chords C_s = (a(s) - a(s')/|a(s)-a(s')|
where s' runs from s around the knot back to s. where at the endpoints we
have +tangent, -tangent. The sum of these vectors divided by the number of
nodes in the curve orthogonalized w.r.t the tangent gives us the next normal vector.
This should mimick the fact that the "center of gravity" lies on the correct
radial chord and that it corresponds to the surface area to the left and right
of our bisecting chord.
See ~ / papers / Dennis_Hannay_ - _Calugareanu_final . pdf Where we " approximate " the bisecting radial chord direction simply by summing the points on the chords C_s = ( a ( s ) - a ( s ' ) / |a ( s ) - a ( s ' ) | where s ' runs from s around the knot back to s . where at the endpoints we have + tangent - tangent . The sum of these vectors divided by the number of nodes in the curve orthogonalized w . r . t the tangent gives us the next normal vector . This should mimick the fact that the " center of gravity " lies on the correct radial chord and that it corresponds to the surface area to the left and right of our bisecting chord .
void writhe_frame_normals(Tube<Vector3>* t, Vector3* Normals) {
  int Nloc = t->nodes();
  Vector3 e_ij, down_dir, tan;
  for (int i=0;i<Nloc;i++) {
    tan = (*t)[i].getTangent();
    vector<Biarc<Vector3> >::iterator bi_tmp, b_i = t->begin()+i;
    vector<Biarc<Vector3> >::iterator b_j = b_i + 1;
    if (b_j == t->end()) b_j = t->begin();
    down_dir = tan;
    while (b_j!=b_i) {
      e_ij = (b_j->getPoint()-b_i->getPoint());
      e_ij.normalize();
      down_dir += e_ij;
      b_j = b_j + 1;
      if (b_j == t->end()) b_j = t->begin();
    }
    down_dir += -tan;
    down_dir/= (float)(Nloc+1);
    down_dir = down_dir - down_dir.dot(tan)*tan;
    down_dir.normalize();
    Normals[i] = down_dir;
  }
}
void writhe_frame_normals ( Tube < Vector3 > * t , Vector3 * Normals ) { int Nloc = t -> nodes ( ) ; Vector3 e_ij , down_dir , tan ; for ( int i = 0 ; i < Nloc ; i ++ ) { tan = ( * t ) [ i ] . getTangent ( ) ; vector < Biarc < Vector3 > > :: iterator bi_tmp , b_i = t -> begin ( ) + i ; vector < Biarc < Vector3 > > :: iterator b_j = b_i + 1 ; if ( b_j == t -> end ( ) ) b_j = t -> begin ( ) ; down_dir = tan ; while ( b_j != b_i ) { e_ij = ( b_j -> getPoint ( ) - b_i -> getPoint ( ) ) ; e_ij . normalize ( ) ; down_dir += e_ij ; b_j = b_j + 1 ; if ( b_j == t -> end ( ) ) b_j = t -> begin ( ) ; } down_dir += - tan ; down_dir /= ( float ) ( Nloc + 1 ) ; down_dir = down_dir - down_dir . dot ( tan ) * tan ; down_dir . normalize ( ) ; Normals [ i ] = down_dir ; } }
See ~/papers/Dennis_Hannay_-_Calugareanu_final.pdf
  Where we "approximate" the bisecting radial chord direction
  simply by summing the points on the chords C_s = (a(s) - a(s')/|a(s)-a(s')|
  where s' runs from s around the knot back to s. where at the endpoints we
  have +tangent, -tangent.
See ~ / papers / Dennis_Hannay_ - _Calugareanu_final . pdf Where we " approximate " the bisecting radial chord direction simply by summing the points on the chords C_s = ( a ( s ) - a ( s ' ) / |a ( s ) - a ( s ' ) | where s ' runs from s around the knot back to s . where at the endpoints we have + tangent - tangent .
// tmp.append(e_ij,Vector3(0,0,0));