I'm trying to animate a pyramid (with any base) opening its lateral faces like a flower. I found the best way to this to be the Rotate function.
The problem is, I have no clue how it works. I have read the documentation page and tried some simple examples but every time the rotation I end up with seems completely random to me.
The pyramid has its center in the origin and it's built with the following function:
myPyramid[edges_, open_] := (
points = Map[Append[#, 0] &, CirclePoints[edges]];
apex = {0, 0, 2};
base = Polygon[points];
points = Append[points, points[[1]]];
faces = Partition[points, 2, 1];
{Map[Rotate[ Polygon[Join[#, {apex}]],
open Degree, #[[2]] , #[[1]]] &, faces], base}
)
Since I need to rotate a Polygon around its base I though the function I was looking for was
Rotate[g,θ,w,p] rotates around the 3D vector w anchored at p.
However the result is not what I was looking for; the faces detach from the base and start rotating around a vertex.
Manipulate[Graphics3D[myPyramid[5, x],
Axes -> True, PlotRange -> {{-2, 2}, {-2, 2}, {-1, 3}}], {x, 0, 90}]
Can anyone please explain to me how does Rotate works in 3D and/or how to rotate said faces the way I want?
#[[2]] - #[[1]]
as the 3rd argument to Rotate $\endgroup${p, q}
. The vector you want to rotate around runs from p to q, and that vector is given byq - p
. $\endgroup$