Matrix of POV for graphs: $\mathbb{R}^n\to \mathbb{R}^2$

107 Views Asked by At

Despite the context, this question concerns mathematics since I ask to find the formula of a matrix, I specify this since the question was closed because "This question is not about mathematics".
This matrix can be used also in other programs besides LaTeX, such as Desmos (of which I give several examples), Geogebra, Matlab or any other program capable of plotting graphs.

Context

I want to make some drawings in $\LaTeX$ and Desmos that represent $n$-dimensional objects.

In general I have made a lot of three-dimensional drawings and I know that $\LaTeX$ has already implemented environments that plot three-dimensional figures but:

  1. The quality is very bad.
  2. Requires a lot of compilation time.

In fact I rarely use that environment

My work

So just out of curiosity I tried to calculate the transformation that, given a given point $(x,y,z)$, projects it to me according to my point of view $(\phi_1,\phi_2)$, and this transformation came out:

$$\bbox[15px,#E0EFFF,border:5px groove #0058B3]{\begin{pmatrix}x'\\y'\end{pmatrix}= \begin{pmatrix} \cos(\phi_1)&-\sin(\phi_2)&0\\ \sin(\phi_1)\cos(\phi_2)&\cos(\phi_1)\cos(\phi_2)&-\sin(\phi_1) \end{pmatrix}\begin{pmatrix}x\\y\\z\end{pmatrix}}$$

I call the matrix the POV (2,3) matrix for brevity (since it shows $\mathbb{R}^3$ over $\mathbb{R}^2$ and the matrix has dimension $2\times 3$).

Some applications

Some graph on Desmos showing:

  1. A rotating dodecahedron

  2. The arg function $z=\text{arg}(x+iy)$

  3. The Mobius strip

  4. The Dini's surface

  5. Some rotating gears

  6. A shell

  7. A double torus

  8. The solution of the heat equation

  9. The solution of the porous media equation

  10. Some images all generated in the $\color{red}{\textbf{two-dimensional}}$ environment of $\LaTeX$ using the POV matrix instead of the $3D$ environment.

enter image description here

enter image description here

enter image description here

The compilation time of these graphs is a few seconds, while using the $3D$ environment it takes much longer and the result has worse quality

Question (partially answered)

I would like to generalize the POV (2,3) matrix: in this case it transforms $\mathbb{R}^3$ vectors into $\mathbb{R}^2$ vectors, but I would like to find a general formula such that it converts vectors from $\mathbb{R}^n$ to vectors in $\mathbb{R}^{n-1}$, in such a way that by multiplying them together I can transform vectors from $\mathbb{R}^n$ to vectors in $\mathbb{R}^2$ and make graphs that require little compilation time (I would also be very curious to see what happens when transforming from $\mathbb{R}^4$ to $\mathbb{R}^3$).

It seems quite useful to me and I think someone has already done it but I haven't been able to find it (maybe it's used for video games or I think it could be applied to rituals where three-dimensional images need to be shown). I call it "POV matrix", but it could have another name perhaps.

Update

I calculate the POV (3,4) matrix and the POV (2,4) matrix (so I changed the title of the question)

$$POV_{3,4}=\begin{pmatrix} \cos(\phi_1)&-\sin(\phi_1)&0&0\\\sin(\phi_1)\sin(\phi_2)&\cos(\phi_1)\cos(\phi_2)&-\sin(\phi_2)&0\\\sin(\phi_1)\sin(\phi_2)\cos(\phi_3)&\cos(\phi_1)\sin(\phi_2)\cos(\phi_3)&\cos(\phi_2)\cos(\phi_3)&-\sin(\phi_3) \end{pmatrix}$$

And $POV_{2,4}=POV_{2,3}\cdot POV_{3,4}$:

$$POV_{2,4}=\begin{pmatrix}\cos\left(\phi_1\right)^2 - \sin^2\left(\phi_1\right) \sin\left(\phi_2\right) & -\sin\left(\phi_1\right) \cos\left(\phi_1\right) - \sin\left(\phi_1\right) \cos\left(\phi_1\right) \cos\left(\phi_2\right) & \sin\left(\phi_1\right) \sin\left(\phi_2\right) & 0\\ -\sin^2\left(\phi_1\right) \sin\left(\phi_2\right)\cos\left(\phi_3\right) + \sin\left(\phi_1\right) \cos\left(\phi_1\right) \cos\left(\phi_2\right) + \sin\left(\phi_1\right) \cos\left(\phi_1\right) \sin\left(\phi_2\right) \cos\left(\phi_2\right) & -\sin\left(\phi_1\right) \cos\left(\phi_1\right) \sin\left(\phi_2\right) \cos\left(\phi_3\right) + \cos^2\left(\phi_1\right) \cos^2\left(\phi_2\right) - \sin^2\left(\phi_1\right) \cos\left(\phi_2\right) & -\sin\left(\phi_1\right) \cos\left(\phi_2\right) \cos\left(\phi_3\right) - \cos\left(\phi_1\right) \sin\left(\phi_2\right) \cos\left(\phi_2\right) & \sin\left(\phi_1\right) \sin\left(\phi_3\right)\end{pmatrix}$$


Only the POV (2,n) matrix is ​​missing

$$POV_{2,n}=POV_{2,3}\cdot POV_{3,4}\cdot... \cdot POV_{n-1,n}$$