%% Curve Invariants
% These are the commands for computing the geometric invariants that
% characterize a parametrized curve.

% In the following, r = [x(t), y(t), z(t)] is a parametrized curve. For
% each such curve, the following program computes its geometric invariants.

realdot = @(x,y) x*transpose(y);
vectorlength = @(x) sqrt(simplify(realdot(x,x)));
velocity = @(r, t) diff(r, t);
acceleration = @(r, t) simplify(diff(r, t, 2));
thirdder = @(r, t) simplify(diff(acceleration(r,t),t));
speed = @(r, t) vectorlength(velocity(r, t));
vta = @(r, t) simplify(cross(velocity(r, t), ...
acceleration(r, t)));
UT = @(r, t) unitvector(velocity(r, t));
UN = @(r, t) unitvector(diff(UT(r, t), t));
UB = @(r, t) simplify(cross(UT(r, t), UN(r, t)));
curvature = @(r, t) simplify(vectorlength(vta(r, t))/speed(r, t)^3);
torsion = @(r, t) simplify ...
    (realdot(vta(r, t), thirdder(r, t))/realdot(vta(r, t), vta(r, t)));