Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BrianWeinstein/ee65f3ed8b094e36a50e to your computer and use it in GitHub Desktop.
Save BrianWeinstein/ee65f3ed8b094e36a50e to your computer and use it in GitHub Desktop.
x[n_, \[Theta]_] := 2*Cos[Pi/(2*n)]*Cos[(1/2)*(\[Theta] + (Pi/n)*(2*Floor[(n*\[Theta])/(2*Pi)] + 1))] - Cos[(Pi/n)*(2*Floor[(n*\[Theta])/(2*Pi)] + 1)]
y[n_, \[Theta]_] := 2*Cos[Pi/(2*n)]*Sin[(1/2)*(\[Theta] + (Pi/n)*(2*Floor[(n*\[Theta])/(2*Pi)] + 1))] - Sin[(Pi/n)*(2*Floor[(n*\[Theta])/(2*Pi)] + 1)]
reuRotate[n_, \[Phi]_] :=
{pts[n, \[Phi]] = Table[RotationMatrix[\[Phi]] . {x[n, \[Theta]], y[n, \[Theta]]}, {\[Theta], 0, 2*Pi, (2*Pi)/100}];
xmin = Min[pts[n, \[Phi]][[All,1]]];
ymin = Min[pts[n, \[Phi]][[All,2]]];
xmax = Max[pts[n, \[Phi]][[All,1]]];
ymax = Max[pts[n, \[Phi]][[All,2]]];
ParametricPlot[
RotationMatrix[\[Phi]] . {x[n, \[Theta]], y[n, \[Theta]]},
{\[Theta], 0, 2*Pi},
PlotStyle -> Thickness[0.009],
PlotRange -> {{xmin, xmax}, {ymin, ymax}}, Axes -> False,
Background -> Darker[Gray, 0.75],
PlotRangePadding -> None
]
}[[1]]
Manipulate[reuRotate[n, \[Phi]], {n, 3, 15, 2}, {\[Phi], 0, 2*Pi}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment