I created a path:

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

BaseRadius = 3;
vecPC = {{(BaseRadius - radius[alpha])*
     Cos[alpha]}, {(BaseRadius - radius[alpha])*
     Sin[alpha]}}; (*vector*)

ParametricPlot[Flatten[vecPC], {alpha, 0, 2*Pi}, PlotStyle -> Blue, 
 ImageSize -> Medium, PlotRange -> 4]

enter image description here

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 ?


1 Answer 1


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]]

curve and normals

  • $\begingroup$ 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. $\endgroup$
    – james
    Commented Oct 24, 2017 at 14:59
  • $\begingroup$ How do you define the cross product of a two-vector? $\endgroup$ Commented Oct 24, 2017 at 15:00
  • $\begingroup$ 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 ? $\endgroup$
    – james
    Commented Oct 24, 2017 at 15:03
  • $\begingroup$ 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. $\endgroup$ Commented Oct 24, 2017 at 15:12
  • 1
    $\begingroup$ @totyped you do know that cam mechanisms are supposed to be continuous to the first derivative to avoid problems. $\endgroup$
    – joojaa
    Commented Oct 24, 2017 at 20:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.