5
$\begingroup$

I've been wondering about how people seem to rotate graphs on a 2D area, and came across this Desmos 2D graph, found Here (desmos.com). Once I saw this, I looked at the equations and was blown by the complexity to rotate them with different variables ($a$, $b$, and $c$). An example of the one of the equations of the points, which are cartesian in the format of $(x,y)$:
$\left(\cos (u)\cos (v)-\sin (u)\cos (v)+\sin (v),\sin (u)\sin (w)-\cos (u)\sin (v)\cos (w)+\sin (u)\sin (v)\cos (w)+\cos (u)\sin (w)+\cos (v)\cos (w)\right)$
Quite the long equation to find a point- but understandable. I'm just interested in knowing the mathematical reasoning behind him using the functions to find the location of the points, not the lines (They are just connecting multiple points). Is this related to the rotation matrix in any way? Or is it using something else that I could possibly know the name of so I could pursue future research? Thanks!

  • 0
    There are eight points and twelve lines in the picture. Let's say we initially have a line $L$ connecting points $p_1,p_2$. After we rotate $p_1,p_2$ to $p_1',p_2'$, the line $L$ should be rotated to the line $L'$ connecting $p_1',p_2'$. Given two points, you can write explicitly a parametrization of the line connecting them so to know $L'$ it is enough to know $p_1',p_2'$. More explicitly, the parametrization of the original line $L$ is $t p_1 + (1 - t) p_2$ (with $0 \leq t \leq 1$) and after the rotation it is $t p_1' + (1 - t) p_2'$ (you can indeed check this is how equations 15-26 are made2017-02-05
  • 0
    Thanks! Is there any reasoning on why this works?2017-02-05
  • 0
    I'm not sure what you're asking. The "rotations" done in the demo (which are in fact projections of true rotations) are linear and so they carry lines to lines. Hence, it is enough to keep track of the end points of the lines.2017-02-05
  • 0
    More specifically, what I wanted to know is the way to rotate $p_1,p_2$ to $p′_1, p′ _2$. Maybe I am just not understanding your answer correctly- If I am just misunderstanding, I must need to rethink it.2017-02-05
  • 0
    No, it seems I misunderstood your question. I just commented on how to keep track of the lines but you are more interested in how to "rotate" the points.2017-02-05

1 Answers 1

5

Set all parameters $a, b, c$ to $0$ and then you get a square on the $xy$ plane with vertices at $(\pm 1, \pm 1$). Imagine that this is what you see when you look at a cube in $\mathbb{R}^3$ whose vertices are $(\pm 1, \pm 1, \pm 1)$ "from above" (that is, from the $z$ axis to the $xy$ plane). From this perspective, the upper face of the cube (with vertices $(\pm 1, \pm 1, 1)$) completely hides away the lower face of the cube (with vertices $(\pm 1, \pm 1, -1)$) and so you can only see a square.

Now, if you change the $b$ parameter (where $b = \pi v$), the square gets rotated on the $xy$ plane. This corresponds to rotating the cube around the $z$-axis. Changing the $a$ parameter (where $a = \pi u$) corresponds to rotating the cube around the $y$ axis and changing the $c$ parameter (where $c = \pi w$) corresponds to rotating the cube around the $x$ axis. Each such rotation can be done by multiplication with an appropriate rotation matrix. In this case, a possible formula for transforming a point $(x,y,z)^T$ is given by

$$ \begin{pmatrix} x \\ y \\ z \end{pmatrix} \mapsto \begin{pmatrix} 1 & 0 & 0 \\ 0 & \cos w & \sin w \\ 0 & -\sin w & \cos w \end{pmatrix} \begin{pmatrix} \cos v & \sin v & 0 \\ -\sin v & \cos v & 0 \\ 0 & 0 & 1 \end{pmatrix} \begin{pmatrix} \cos u & 0 & -\sin u \\ 0 & 1 & 0 \\ \sin u & 0 & \cos u \end{pmatrix} \begin{pmatrix} x \\ y \\ z \end{pmatrix} \\ = \begin{pmatrix} \cos u \cos v & \sin v & -\cos v \sin u \\ \sin u \sin w - \cos u \cos w \sin v & \cos v \cos w & \cos w \sin u \sin v + \cos u \sin w \\ \cos w \sin u + \cos u \sin v \sin w & -\cos v \sin w & \cos u \cos w - \sin u \sin v \sin w\end{pmatrix} \begin{pmatrix} x \\ y \\ z \end{pmatrix}. $$

This corresponds to performing first a rotation in the $xz$ plane, then a rotation in the $xy$ plane and finally a rotation in the $yz$ plane (and this is indeed the formula the application uses).

We look at the picture from above and so we are interested only in the $xy$-components of the result giving us

$$ \begin{pmatrix} x \\ y \\ z \end{pmatrix} \mapsto \begin{pmatrix} x \cos u \cos v + y \sin v - z \cos v \sin u \\ x (\sin u \sin w - \cos u \cos w \sin v) + y \cos v \cos w + z (\cos w \sin u \sin v + \cos u \sin w )\end{pmatrix}. $$

For example, point number $7$ in the application correspond to the vertex $(1,1,1)$ of the cube. Hence, the formula for changing $(1,1,1)$ in terms of $u,v,w$ is given by

$$ \begin{pmatrix} \cos u \cos v + \sin v - \cos v \sin u \\ \sin u \sin w - \cos u \cos w \sin v + \cos v \cos w + \cos w \sin u \sin v + \cos u \sin w \end{pmatrix} $$

which is the formula you wrote in the question.

To summarize, the person who wrote the application considered a cube in 3D and projected it (orthogonally) to the $xy$ plane (2D). By modifying three parameters, you can rotate the vertices and edges of the cube in 3D and see the projected result in 2D.

  • 0
    This is exactly what I wanted- Thank you so much for letting me know!2017-02-05