Tangent, Normal, and Binormal Vectors

4431 days ago by pub

def tangentVector(r, t): return diff(r, t) / norm(diff(r, t)) def normalVector(r, t): T = tangentVector(r, t) return diff(T, t) / norm(diff(T, t)) def binormalVector(r, t): T = tangentVector(r, t) N = normalVector(r, t) return T.cross_product(N) def curvature(r, t): T = tangentVector(r, t) return norm(diff(T, t)) / norm(diff(r, t)) 
       
def plotSpaceCurve(r, t, tmin, tmax, **kwarg): return parametric_plot3d(list(r), (t, tmin, tmax), **kwarg) def plotTangentVector(r, t, t0, **kwarg): var('u') r0 = r(t = t0) T = tangentVector(r, t)(t = t0) return parametric_plot3d(list(r0 + u * T), (u, 0, 1), **kwarg) def plotNormalVector(r, t, t0, **kwarg): var('u') r0 = r(t = t0) N = normalVector(r, t)(t = t0) return parametric_plot3d(list(r0 + u * N), (u, 0, 1), **kwarg) def plotBinormalVector(r, t, t0, **kwarg): var('u') r0 = r(t = t0) B = binormalVector(r, t)(t = t0) return parametric_plot3d(list(r0 + u * B), (u, 0, 1), **kwarg) def plotNormalPlane(r, t, t0, **kwarg): var('u v') r0 = r(t = t0) N = normalVector(r, t)(t = t0) B = binormalVector(r, t)(t = t0) return parametric_plot3d(list(r0 + u * N + v * B), (u, -1, 1), (v, -1, 1), **kwarg) def plotOsculatingPlane(r, t, t0, **kwarg): var('u v') r0 = r(t = t0) T = tangentVector(r, t)(t = t0) N = normalVector(r, t)(t = t0) return parametric_plot3d(list(r0 + u * T + v * N), (u, -1, 1), (v, -1, 1), **kwarg) def plotRectifyingPlane(r, t, t0, **kwarg): var('u v') r0 = r(t = t0) T = tangentVector(r, t)(t = t0) B = binormalVector(r, t)(t = t0) return parametric_plot3d(list(r0 + u * T + v * B), (u, -1, 1), (v, -1, 1), **kwarg) def plotInscribedCircle(r, t, t0, **kwarg): var('u') r0 = r(t = t0) N = normalVector(r, t)(t = t0) radius = 1 / curvature(r, t)(t = t0) center = r0 + radius * N T = tangentVector(r, t)(t = t0) return parametric_plot3d(list(radius * (N * cos(u) + T * sin(u)) + center), (u, 0, 2 * pi), **kwarg) 
       
var('t') r = vector([cos(t), sin(t), t]) 
       
@interact def _(doTV = ("Draw Tangent Vector", True), doNV = ("Draw Normal Vector", True), doBV = ("Draw Binormal Vector", True), doNP = ("Draw Normal Plane", True), doOP = ("Draw Osculating Plane", True), doRP = ("Draw Rectifying Plane", True), doIC = ("Draw Inscribed Circle", True), t0 = (0, (-pi.n(), pi.n()))): show(r) P = plotSpaceCurve(r, t, -pi, pi, aspect_ratio = [1, 1, 1], color = "black", thickness = 2) if doTV: P += plotTangentVector(r, t, t0, color = "blue", thickness = 2) if doNV: P += plotNormalVector(r, t, t0, color = "green", thickness = 2) if doBV: P += plotBinormalVector(r, t, t0, color = "red", thickness = 2) if doNP: P += plotNormalPlane(r, t, t0, color = "blue", opacity = 0.2) if doOP: P += plotOsculatingPlane(r, t, t0, color = "red", opacity = 0.2) if doRP: P += plotRectifyingPlane(r, t, t0, color = "green", opacity = 0.2) if doIC: P += plotInscribedCircle(r, t, t0, color = "red", thickness = 2) show(P) 
       

Click to the left again to hide and once more to show the dynamic interactive window