Wolfram Mathematica Code
Wolfram Mathematica Code
r1[x_] := x, x2
(* calculate curvature, unit tangent vector *)
(* and unit normal vectors *)
fs1 = FrenetSerretSystem[r1[x], x]
2 1 2x 2x 1
Out[456]= , , , - ,
3/2
1 + 4 x2 1 + 4 x2 1 + 4 x2 1 + 4 x2 1 + 4 x2
In this case, the curvature at x = 0.5 is positive and the unit normal vector points toward the center of
curvature.
In[461]:= (* curvature at x=0.5 *)
fs1〚1, 1〛 /. x 0.5
Out[461]= 0.707107
2 directionOfUnitNormal.nb
Out[462]=
0.5
x
0 0.5 1
In this case, the curvature at t = 0.5 is negative and the unit normal vector points away from the center
of curvature.
In[468]:= fs2〚1, 1〛 /. x 0.5
Out[468]= - 0.3849
In[469]:= Show[
ParametricPlot[r2[x], {x, 0, 1}, ImageSize 150,
PlotRange {{- 0.5, 1}, {0, 1.5}}, AspectRatio Automatic,
AxesLabel {"x", "y"}, Ticks {{0, .5, 1}, {0, .5, 1, 1.5}}],
Graphics[{
Red, Point[r2[.5]],
Arrow[{r2[.5], r2[.5] + nHat2}]
}]
]
y
1.5
Out[469]=
0.5
x
0 0.5 1
There is a way to deal with this using the built-in function Sign.
(* here is the curvature at t=0.5 *)
fs2〚1, 1〛 /. x 0.5
(* and here is the unit normal at t=0.5 *)
(* remember, this is the unit normal *)
(* that points away from the center of curvature *)
fs2〚2, 2〛 /. x 0.5
Out[470]= - 0.3849
Here is the unit normal taking into account of the sign of the curvature.
In[477]:= (Sign[fs2〚1, 1〛] × fs2〚2, 2〛) /. x 0.5
Out[477]= {0.57735, - 0.816497}