# Find normal vector of path

I created a path:

path[x_] := TriangleWave[x*3]
radius[alpha_] := path[alpha/(2 Pi)];

Sin[alpha]}}; (*vector*)

ParametricPlot[Flatten[vecPC], {alpha, 0, 2*Pi}, PlotStyle -> Blue,
ImageSize -> Medium, PlotRange -> 4] Now I want to calulate the normal vector of the path at each point. How can you do it ?

As a plus: How can I display some normal vectors along the path ?

• – Artes Oct 24 '17 at 15:27

After simplifying your code quite a bit:

With[{BaseRadius = 3, h = 0.4, n = 45},
pos[t_] := (BaseRadius - TriangleWave[3 t/(2 π)]) {Cos[t], Sin[t]};
nrm[t_] = Normalize[Cross[pos'[t]]];
ParametricPlot[pos[t], {t, 0, 2 π},
Epilog -> {Directive[Red, Arrowheads[Small]],
Table[Arrow[{pos[t], pos[t] - h nrm[t]}],
{t, 0, 2 π, 2 π/(n - 1)}]},
PlotRange -> 4, PlotStyle -> Blue]] • Thank you very much for this beautiful and very readable answer !! May I bother you for another question ? How can I take the cross product of the normal (calculated here) and another vector ? I already tried Cross[nrm[t_],vect2] but it does not work. This path should be used as a cam drive, and therefore the torque on the camshaft should be computed. – james Oct 24 '17 at 14:59
• How do you define the cross product of a two-vector? – J. M. will be back soon Oct 24 '17 at 15:00
• Hmm ...it is still not working. I tried this: radiusVec[t_] = {Cos[t], Sin[t]}; Cross[nrm[t], radius[t]]. I define the cross product as cross(a,b) = |a||b|cos(phi), where phi is the angle between a and b. I though Mathematica would do it automatically ? – james Oct 24 '17 at 15:03
• That's the dot product... unfortunately Cross[] is not compatible with 2-vectors (except in the use case I gave for generating a normal vector). That's why I was asking for the definition that you use, since you can just implement that manually. – J. M. will be back soon Oct 24 '17 at 15:12
• @totyped you do know that cam mechanisms are supposed to be continuous to the first derivative to avoid problems. – joojaa Oct 24 '17 at 20:40