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$ Commented May 18, 2021 at 18:16
  • $\begingroup$ Thank you! This was very helpful! $\endgroup$ Commented May 18, 2021 at 18:27
  • 2
    $\begingroup$ related/possible duplicate: How to project 3d image in the planes xy, xz, yz? $\endgroup$ Commented May 18, 2021 at 21:17

3 Answers 3

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

Using ProjectGraphics3D by Wolfram Staff

p = ResourceFunction["ProjectGraphics3D"]; c = ColorData[97, "ColorList"]; f = {(1 + Cos[3 t]) Cos[t], (1 + Cos[3 t]) Sin[t], Sin[3 t]}; plot = ParametricPlot3D[f, {t, 0, 2 Pi}, PlotStyle -> c[[1]]]; d = 3; Show[ plot, p[plot, {0, +d, 0}, PlotStyle -> {c[[2]]}], p[plot, {-d, 0, 0}, PlotStyle -> {c[[3]]}], p[plot, {0, 0, -d}, PlotStyle -> {c[[4]]}], AxesLabel -> {"X", "Y", "Z"}, PlotRange -> All] 

enter image description here

$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.