4
$\begingroup$

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.

$\endgroup$
3
  • 1
    $\begingroup$ It's ParametricPlot3D not Parametric3D. Consult the documentation. For the planes, just do three plots and set z to 0, y to 0, and x to zero and wrap in a Show like Show[ParametricPlot3D[...], ParametricPlot3D[...], ParametricPlot3D[...], ParametricPlot3D[...]] $\endgroup$
    – flinty
    May 18, 2021 at 18:16
  • $\begingroup$ Thank you! This was very helpful! $\endgroup$
    – user80088
    May 18, 2021 at 18:27
  • 1
    $\begingroup$ related/possible duplicate: How to project 3d image in the planes xy, xz, yz? $\endgroup$
    – kglr
    May 18, 2021 at 21:17

2 Answers 2

7
$\begingroup$
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

$\endgroup$
3
$\begingroup$

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

$\endgroup$

Your Answer

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

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