How would I draw this in sage? It's a Frenet Trihedron along a given curve:
Tools other then Sage are welcome too.
Im just interested in which equations I need to input, besides the curve to obtain the animation.
How would I draw this in sage? It's a Frenet Trihedron along a given curve:
Tools other then Sage are welcome too.
Im just interested in which equations I need to input, besides the curve to obtain the animation.
I don't yet know Sage well enough to carry this off, but here's some Mathematica code:
fn[t_] := {Cos[t], Sin[t], t/2} fnD1[t_] := Simplify[D[fn[tt], tt] /. tt -> t, Trig -> True] fnD1n[t_] := Simplify[fnD1[t]/Sqrt[fnD1[t].fnD1[t]], Trig -> True] fnD2[t_] := Simplify[D[fnD1n[tt], tt] /. tt -> t, Trig -> True] fnD2n[t_] := Simplify[fnD2[t]/Sqrt[fnD2[t].fnD2[t]], Trig -> True] binormal[t_] := Simplify[Cross[fnD1n[t], fnD2n[t]], Trig -> True] trihedron[t_] := {fn[t], fnD1n[t], fnD2n[t], binormal[t]} curve = ParametricPlot3D[fn[t], {t, 0, 10}]; Animate[ tri = trihedron[t]; Show[{curve, Graphics3D[{Red, Line[{tri[[1]], tri[[1]] + tri[[2]]}], Green, Line[{tri[[1]], tri[[1]] + tri[[3]]}], Blue, Line[{tri[[1]], tri[[1]] + tri[[4]]}]}]}], {t, 0, 10}]
The expression D[f[x],x] computes the derivative of f; Cross computes the cross product; Trig->True instructs Mathematica to simplify trig expressions. You will probably want to hard-code the formulas for fnD1n, fnD2n, and binormal. They are simple enough:
fnD1n[t] = {-Sin[t], Cos[t], 1/2} * (2/Sqrt[5]) fnD2n[t] = {-Cos[t], -Sin[t], 0} binormal[t] = {Sin[t], -Cos[t], 2} * (1/Sqrt[5])
Addendum: As I said, I'm no expert in Sage. I actually didn't think the code above was all that long, but it could have been shortened a bit by hard-coding the formulas for the three unit vectors rather than computing them from the definitions. The latter has the advantage of allowing the code to be easily adapted for other curves.
Here's some code to draw a still image in Sage:
t=var('t'); pl1=parametric_plot3d( (cos(t), sin(t), t/2), (t, 0, 10)); a=9; pl2=parametric_plot3d( (cos(a) - t*sin(a)*2/sqrt(5), sin(a)+t*cos(a)*2/sqrt(5), a/2+t*1/2*2/sqrt(5)), (t,0,1), texture="red"); pl3=parametric_plot3d( (cos(a) - t*cos(a), sin(a)-t*sin(a)*2/sqrt(5), a/2+t*0), (t,0,1), texture="green"); pl4=parametric_plot3d( (cos(a) + t*sin(a)*1/sqrt(5), sin(a)-t*cos(a)*1/sqrt(5), a/2+t*2*1/sqrt(5)), (t,0,1), texture="blue"); pl1+pl2+pl3+pl4
You'll see that the unit vectors have been hard-coded in this version. The trihedron is moved along the curve by varying $a$. I haven't figured out how to animate this yet. I have seen examples in the Sage documentation where a 2-D plot is animated, but not 3-D. Apparently there's some work to be done in this area. See the following posts:
http://ask.sagemath.org/question/99/animate-3d-plots
http://ask.sagemath.org/question/1422/3d-animation-with-tachyon
http://freeblogin.blogspot.com/2011/09/sage-devel-animating-3d-plots.html