(* All text between (* ... *) are comments and are ignored by Mathematica.
   This package computes the Frenet frames and related quantities of curves in
   R^3 
	Written 1/31/99 by Takashi Kimura
*) 


(* The Cross Product is Cross[{x1,x2,x3},{y1,y2,y3}] *)


(* The Dot Product is "." *)

(* Norm of a Vector *)
(* Norm[v_] := Sqrt[Sum[v[[i]]^2,{i,1,Length[v]}]] *)
Norm[v_] := Sqrt[v.v]

(* Curvature of a Curve alpha[t] *)
Curvature[alpha_,t_] := Simplify[Norm[Cross[alpha'[t],alpha''[t]]] /Norm[alpha'[t]]^3]

(* Torsion of a Curve alpha[t] *)
Torsion[alpha_,t_] := Simplify[Cross[alpha'[t],alpha''[t]] . alpha'''[t]/Norm[Cross[alpha'[t],alpha''[t]]]^2]

(* Arc Length Function from t=a to t=b *)
Arclength[alpha_,a_,b_] := Simplify[Integrate[Norm[alpha'[t]],{t,a,b}]]

(* Calculate the Frenet Frame Vectors T, B, N *)
FT[alpha_,t_] := Simplify[alpha'[t]/Norm[alpha'[t]]]
FN[alpha_,t_] := Simplify[D[FT[alpha,t],t]/(Curvature[alpha,t] Norm[alpha'[t]])]
FB[alpha_,t_] := Simplify[Cross[FT[alpha,t],FN[alpha,t]]]

(* Involute of alpha[t] *)
Involute[alpha_,t_] := Simplify[alpha[t] - Arclength[alpha,0,t] alpha'[t]/Norm[alpha'[t]]]

(* The Plane Evolute of alpha[t] -- alpha[t] should lie in the plane here! *)
Evolute[alpha_,t_] := Simplify[alpha[t] + Norm[alpha'[t]]^2/Norm[Cross[alpha'[t],alpha''[t]]]^2 Cross[Cross[alpha'[t],alpha''[t]],alpha'[t]]]
