4

I'm trying to plot a trefoil with a parametric function in Mathematica. How would I do that? I know I can use Parametric3D to depict all of it but how do I project it on the XY, XZ, and YZ planes?

It's function is $r(t)= ((1+\cos(3t))\cos(t),(1+\cos(3t)\sin(t), \sin(3t)$.

Thank you.

user80088
  • 91
  • 2

2 Answers2

7
Clear["Global`*"]

r[t_] = {(1 + Cos[3 t]) Cos[t], (1 + Cos[3 t]) Sin[t], Sin[3 t]};

ParametricPlot3D[{r[t],
  ReplacePart[r[t], 1 -> -1.75],
  ReplacePart[r[t], 2 -> 2.5],
  ReplacePart[r[t], 3 -> -1.5]},
 {t, 0, 2 Pi},
 AxesLabel ->
  (Style[#, 14, Bold] & /@ {x, y, z}),
 PlotLegends -> {"r(t)", "YZ", "XZ", "XY"}]

enter image description here

EDIT: To see the progression of the parameter

ParametricPlot3D[{r[t],
  ReplacePart[r[t], 1 -> -1.75],
  ReplacePart[r[t], 2 -> 2.5],
  ReplacePart[r[t], 3 -> -1.5]},
 {t, 0, 2 Pi},
 AxesLabel -> (Style[#, 14, Bold] & /@ {x, y, z}),
 PlotLegends -> BarLegend[{"Rainbow", {0, 2 Pi}},
   LegendLabel -> Style[t, 14, Bold]],
 ColorFunction -> Function[{x, y, z, t},
   ColorData["Rainbow"][t]]]

enter image description here

Bob Hanlon
  • 157,611
  • 7
  • 77
  • 198
3

ScalingTransform[{1,1,0}] is the project transformation to X-Y plane etc.

r[t_] := {Cos[t] (1 + Cos[3 t]), (1 + Cos[3 t]) Sin[t], 
  Sin[3 t]}; 
Show[
 ParametricPlot3D[
  Through@(ScalingTransform /@ {{1, 1, 1}, {1, 1, 0}, {1, 0, 1}, {0, 
         1, 1}})@r[t] // Evaluate, {t, 0, 2 π}, 
  PlotStyle -> {Directive[AbsoluteThickness[3], Red], 
    Directive[Dashed, Green], Directive[Dashed, Cyan], 
    Directive[Dashed, Yellow]}, Boxed -> False, Axes -> False], 
 Graphics3D[{InfinitePlane[{0, 0, 0}, {{1, 0, 0}, {0, 1, 0}}], 
   InfinitePlane[{0, 0, 0}, {{0, 1, 0}, {0, 0, 1}}], 
   InfinitePlane[{0, 0, 0}, {{0, 0, 1}, {1, 0, 0}}]}]]

enter image description here

cvgmt
  • 72,231
  • 4
  • 75
  • 133