Code-Eli  0.3.6
torsion.hpp
Go to the documentation of this file.
1 /*********************************************************************************
2 * Copyright (c) 2013 David D. Marshall <ddmarsha@calpoly.edu>
3 *
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
10 * David D. Marshall - initial code and implementation
11 ********************************************************************************/
12 
13 #ifndef eli_geom_curve_torsion_hpp
14 #define eli_geom_curve_torsion_hpp
15 
16 namespace eli
17 {
18  namespace geom
19  {
20  namespace curve
21  {
22  // FIX: (1) THIS NEEDS A UNIT TEST
23  template<typename curve__>
24  void torsion(typename curve__::data_type &tau, const curve__ &c, const typename curve__::data_type &t)
25  {
26  // check to make sure have valid curve
27  assert(c.degree()>0);
28 
29  // check to make sure given valid parametric value
30  assert((t>=0) && (t<=1));
31 
32  typename curve__::point_type xp(c.fp(t)), xpp(c.fpp(t)), xppp(c.fppp(t)), tmp1;
33  typename curve__::data_type tmp2;
34 
35  tmp1=xp.cross(xpp);
36  tmp2=tmp1.norm();
37  tau=tmp1.dot(xppp)/(tmp2*tmp2);
38  }
39  }
40  }
41 }
42 #endif
void torsion(typename curve__::data_type &tau, const curve__ &c, const typename curve__::data_type &t)
Definition: torsion.hpp:24
Definition: math.hpp:20