(50g) 3D curvature and torsion
01-04-2016, 05:15 PM (This post was last modified: 01-04-2016 05:17 PM by peacecalc.)
Post: #1
 peacecalc Member Posts: 139 Joined: Dec 2013
(50g) 3D curvature and torsion
Hello 50g guys,

after programming for 2D curvature, I extend a program for 3D vectors. A curve in 3D has one parameter, this parameter is named "X", so the CAS command "DERVX" can be used. The program get a vector as input on stack 1 which describe a curve, let say "[ 'X' 'X^2' 'X^3']"

The output on stack 2 is the curvature and for stack 1 the torsion.

Code:
 %%HP: T(3)A(R)F(,); \« DUP DERVX               DUPDUP ABS DUP     ROT SWAP /     EVAL SIMPLIFY     DUP DERVX     DUPDUP ABS DUP     ROT SWAP /     EVAL SIMPLIFY \-> V VA VAA T TA TAA N                           \« TAA VAA /                                EVAL SIMPLIFY                                T N CROSS                                EVAL SIMPLIFY                                DERVX NEG N DOT VAA /                                EVAL SIMPLIFY   \» \»

Don't worry, the program is slow, with input mentioned above you obtain a result after 65 sec...
The results are:

stack 2: $(\kappa=)\frac{2\cdot\sqrt{81X^8+117X^6+54X^4+13x^2+1}}{81X^8+72X^6+34X^4+8x^2+1​}$

stack 1: $(\tau=)\frac{3}{9X^4+9X^2+1}$

The result for the curvature can simplified to with the help of the CAS command "FACTOR" (used extra for denominator and numerator) to the expression:

$(\kappa=)\frac{2\cdot\sqrt{9X^4+9X^2+1}}{\left(\sqrt{9X^4+4X^2+1}\right)^3}$

Feel free and enjoy the little program!
Every constructive critics or suggestions for improvement are welcome.

Greetings peacecalc
 « Next Oldest | Next Newest »

User(s) browsing this thread: 1 Guest(s)