|
本帖最后由 hbghlyj 于 2023-9-12 10:22 编辑 desmos.com/calculator/zc11cndy1m
Please scroll down in this panel to read!
Rotate the green cube using the sliders below:
$\phi_{x}=0.86$
$\phi_{y}=-0.33$
$\phi_{z}=0.92$
Change the view of the project by dragging the black point.
Drag the purple point (labelled 'Screen') to move the screen.
You can also drag anywhere else on the canvas to move around.
Thinking about two and three dimensional objects is commonplace to everyday life. We find it natural to do so, since we are able to relate these concepts to the world we live in. However, the idea of a higher dimensional object is less tangible. We can all conjure up a clear image in our head when we are told to think about a three dimensional cube, but what about a four dimensional one? It seems strange, perhaps even illogical that there should be such an abrupt cut-off point between three and four dimensions. In fact, we shall find that if we first take a step back and break down the process through which we view three dimensional objects, we can extend our method to four or more dimensions.
When thinking about how to visualise a higher dimensional cube, it will help to first think about how we look at a 3D cube on a 2D screen. That is what the canvas on the right shows.
On the canvas, there is a set of 3 axes (x, y, and z) representing 3D space. The green cube is a 3D object. We want to look at this object on a 2D screen.
If we think of the xy-plane (the plane spanned by the red and blue axes) as our screen, the black lines show what we see of our green cube on the screen. We call this image of our cube on the screen its 'projection'.
The purple box shows what we would see if we were looking at the screen head on.
The question is, how do we generate this projection?
EXERCISE: Drag the black point around to try and make the green cube line up with its projection. When you do, what do you notice? What does this tell you about the process?
ANSWER: The two line up when you are either looking down at the green cube from directly above it, or looking up at it from directly below. This tells you that the projection is created by effectively flattening the green cube onto the screen in a direction parallel to the z-axis (orange axis).
Also note that when you line the two up, what you see is identical to what is shown on the purple screen. Why is this?
The process of the projection can also be thought of as taking each vertex of the green cube, and moving it vertically down until it reaches the xy-plane.
Click the circle on the left of the line below.
$\operatorname{polygon}\left(C\left[1\right],C_{1}\left[1\right]\right)$
$\operatorname{polygon}\left(C\left[2\right],C_{1}\left[2\right]\right)$
$\operatorname{polygon}\left(C\left[3\right],C_{1}\left[3\right]\right)$
$\operatorname{polygon}\left(C\left[4\right],C_{1}\left[4\right]\right)$
$\operatorname{polygon}\left(C\left[5\right],C_{1}\left[5\right]\right)$
$\operatorname{polygon}\left(C\left[6\right],C_{1}\left[6\right]\right)$
$\operatorname{polygon}\left(C\left[7\right],C_{1}\left[7\right]\right)$
$\operatorname{polygon}\left(C\left[8\right],C_{1}\left[8\right]\right)$
You should see some purple lines. Each of these lines represent the path a vertex of the green cube would take as it moves down to the xy-plane.
EXERCISE: Say one vertex of the green cube has coordinates (x,y,z). As you move it vertically down to the xy-plane, what does its coordinate become?
ANSWER: It becomes (x,y,0). This is because as we move the vertex down, its x and y coordinates don't change since it is always above the same point on the xy-plane. However, its z coordinate decreases to zero.
Overall, we can conclude that given some point (x,y,z), to project it onto the xy-plane we keep its x and y coordinates the same and make all other coordinates (ie the z coordinate in this case) zero.
This is called the orthogonal (or orthographic) projection. If two things are orthogonal, they are at 90 degrees to each other. Why do you think the projection is given this name?
We have talked about the orthogonal projection in 3D, and now we can think about generalising it to higher dimensions. We have to begin by thinking about what a 'higher dimension' means.
Points in 2D have the form $(x,y)$, and the entirety of 2D space can be thought of as the set of all possible points $(x,y)$. 3D points are of the form $(x,y,z)$, and similarly 3D space is the collection of all such points.
Therefore, it is only natural to extend our definition to more dimensions. 4 dimensional space is defined to be the set of all points of the form $(x,y,z,w)$. More generally, $n$ dimensional space is the set of all points of the form $(x_1,x_2,\dots,x_n)$.
It may be weird to think about this at first, however the reason for making these definitions is such that we can abstract the concept of an $n$-dimensional space away from the real world (which is limited to $n=3$).
If we consider objects and concepts just in terms of these definitions, we see that many familiar ideas, such as squares/cubes, circles/spheres and the orthogonal projection can be generalised.
We now extend our orthogonal projection to higher dimensions. Say we want to project a 4D point (x,y,z,w) onto the xy-plane. You can still think of the xy-plane as a 2D screen, but this time it is placed inside 4D space and you are using it to view a 4D object.
Similar to 3D, we keep the x and y coordinates of the point fixed, and make all other coordinates (ie. z and w) zero. This gives us (x,y,0,0) as our projected point.
In n-dimensional space, the projection of (x1,x2,x3,x4,....,xn) is (x1,x2,0,0,...,0). In other words, all coordinates apart from the first two become zero.
We now discuss the process of visualising a 4D cube.
We call the n-dimensional generalisation of the square an 'n-square'. The familiar 2D square is therefore the '2-square'. We call the cube a '3-square'. It follows that the 4D cube (hypercube) is the '4-square'.
If we just want to use 0s and 1s in the coordinates, a 2-square has vertices at (0,0), (0,1), (1,0) and (1,1).
The vertices of the 3-square are (0,0,0), (0,0,1), (0,1,0), (0,1,1), (1,0,0), (1,0,1), (1,1,0) and (1,1,1).
EXERCISE: How many vertices does a 4-square have? Can you list them out, or describe how you would list them? What about an n-square?
ANSWER 1: We see that the vertices of the 2-square are all possible combinations of two numbers, each either a 0 or a 1. Order matters here, since (0,1) is not the same as (1,0). Now the same goes for a 3-square. Its vertices are all possible ordered triplets of 0s and 1s.
Consider the vertices of a 4-square. The first coordinate can be a 0 or a 1. In each case, the second coordinate can be a 0 or a 1, giving 4 possible combinations so far. For each of these cases, the third coordinate can be a 0 or a 1. This gives 8 in total. Finally, for each of these 8 cases, there are two options for the final coordinate. Hence, a 4-square has 2^4 = 16 vertices. To list them, we would have to write down all possible ordered quartets of 0s and 1s. Also, by the same logic, an n-square has 2^n vertices.
ANSWER 2: Note that the vertices of the 2-square correspond to all binary numbers of 2 bits. Those of the 3-square correspond to all 3 bit binary numbers. Therefore the vertices of an n-square correspond to all the n bit binary numbers, of which there are exactly 2^n. To list them, we would have to count from 0 to (2^n)-1 in binary. Think about why this is true if you aren't sure.
Once we have all the vertices of a 4-square, we can scale it, move it around and rotate it, if we wish. Then we can project it onto our screen (the xy-plane) by sending each vertex of the form (x,y,z,w) to (x,y,0,0).
This process is exactly what's being done in the link below to visualise a 4-square! The 4-square is moving since we are showing it being rotated as it is projected.
desmos.com/calculator/eknzt6jgdy
In the following link, we use a different projection called the perspective projection to visualise the 4-square. We have not discussed the perspective projection, however the process of thinking about it in 3D and then generalising it to higher dimensions can still be applied.
desmos.com/calculator/ifuuoal41u
Some extra discussions that may be of interest are below.
What would we do if we don't want to project onto the xy-plane? In other words, what if our screen doesn't happen to be the xy-plane?
To answer this, say we want to project n-dimensional space (denoted as $R^n$) onto a plane P. We can apply a transformation T (specifically a translation followed by a rotation) to R^n. This will give us a transformed version of the space, $T(R^n)$. We want T to be such that after the transformation, the plane P coincides with the xy-plane. We can then project $T(R^n)$ onto the xy-plane for the same effect as projecting R^n onto P. This is because R^n relative to P is identical to $T(R^n)$ relative to the xy-plane.
EXERCISE: Do you think the human eye sees in an orthographic projection? Why or why not? As a hint, think about certain properties of objects that the orthographic projection preserves. Do our eyes preserve these properties?
EXERCISE: Define the Euclidean norm of a point $(x_1,x_2,\dots,x_n)$ to be the square root of $x_1^2 + x_2^2 +\dots+ x_n^2$. The unit n-dimensional sphere is defined to be the set of all points in R^n with Euclidean norm 1. Describe what you see when you take the orthographic projection of a unit n-dimensional sphere centred on the origin onto the xy-plane. Here n is greater than or equal to 3. First you should think about the 3D sphere, and what its projection looks like.
EXERCISE: What do we rotate objects around in 4 dimensions? What do we reflect objects in in 4 dimensions? What about n-dimensions?
Below is the maths to make this interactive project work. Feel free to have a poke around, I have tried to put explanations for what everything does!
Draw projections of cube and its projection
Generate coordinates for the vertices of the cube. $(C_x, C_y, C_z)$ gives all vertices of the cube. An alternative fun way to implement this (which you can try) is to use a function that, given some number n, returns the i-th digit of the binary representation of n.
$C_{ubeBase}=\left[0...7\right]$
$C_{X}=\operatorname{sign}\left(C_{ubeBase}-3.5\right)$
$C_{Y}=\operatorname{sign}\left(\operatorname{mod}\left(C_{ubeBase},\ 4\right)-1.5\right)$
$C_{Z}=\operatorname{sign}\left(\operatorname{mod}\left(C_{ubeBase},\ 2\right)-0.5\right)$
R_cube is a rotation first about the z-axis, then the y-axis, and finally the x-axis.
$R_{cube}=M_{M}\left(R_{X}\left(\phi_{x}\right),\left(M_{M}\left(R_{Y}\left(\phi_{y}\right),R_{Z}\left(\phi_{z}\right)\right)\right)\right)$
First rotate cube using R_cube, then translate cube parallel to z-axis. Finally return coordinates for the vertices of the transformed cube.
$V_{ertShift}=3.93$
$C_{ubeX}=M_{V1}\left(R_{cube},C_{X},C_{Y},C_{Z}\right)$
$C_{ubeY}=M_{V2}\left(R_{cube},C_{X},C_{Y},C_{Z}\right)$
$C_{ubeZ}=M_{V3}\left(R_{cube},C_{X},C_{Y},C_{Z}\right)+V_{ertShift}$
$C=P_{roj}\left(C_{ubeX},C_{ubeY},C_{ubeZ}\right)$
$\operatorname{polygon}\left(C\left[1\right],C\left[2\right],C\left[4\right],C\left[3\right]\right)$
$\operatorname{polygon}\left(C\left[5\right],C\left[6\right],C\left[8\right],C\left[7\right]\right)$
$\operatorname{polygon}\left(C\left[2\right],C\left[6\right],C\left[5\right],C\left[1\right]\right)$
$\operatorname{polygon}\left(C\left[3\right],C\left[7\right],C\left[8\right],C\left[4\right]\right)$
$C_{1}=P_{roj}\left(C_{ubeX},C_{ubeY},0\right)$
$\operatorname{polygon}\left(C_{1}\left[1\right],C_{1}\left[2\right],C_{1}\left[4\right],C_{1}\left[3\right]\right)$
$\operatorname{polygon}\left(C_{1}\left[5\right],C_{1}\left[7\right],C_{1}\left[8\right],C_{1}\left[6\right]\right)$
$\operatorname{polygon}\left(C_{1}\left[3\right],C_{1}\left[7\right]\right)$
$\operatorname{polygon}\left(C_{1}\left[1\right],C_{1}\left[5\right]\right)$
$\operatorname{polygon}\left(C_{1}\left[2\right],C_{1}\left[6\right]\right)$
$\operatorname{polygon}\left(C_{1}\left[4\right],C_{1}\left[8\right]\right)$
Control position of screen.
$S_{crX}=10.04$
$S_{crY}=5.52$
$\left(S_{crX},S_{crY}\right)$
Draw screen border.
$B_{oundX}=2.8$
$B_{oundY}=5.15$
$\operatorname{polygon}\left(S_{crX}+\left[1,1,-1,-1\right]B_{oundX},S_{crY}+\left[0,-1,-1,0\right]B_{oundY}-0.5\right)$
Draw cube's projection. This is what we see if we look at the cube from directly above or below it.
$S_{L}=\left(C_{ubeX}+S_{crX},C_{ubeY}+S_{crY}-3\right)$
$\operatorname{polygon}\left(S_{L}\left[1\right],S_{L}\left[2\right],S_{L}\left[4\right],S_{L}\left[3\right]\right)$
$\operatorname{polygon}\left(S_{L}\left[5\right],S_{L}\left[6\right],S_{L}\left[8\right],S_{L}\left[7\right]\right)$
$\operatorname{polygon}\left(S_{L}\left[5\right],S_{L}\left[6\right],S_{L}\left[2\right],S_{L}\left[1\right]\right)$
$\operatorname{polygon}\left(S_{L}\left[3\right],S_{L}\left[4\right],S_{L}\left[8\right],S_{L}\left[7\right]\right)$
3D projection
$R_{ange}=4.5$
$\left[P_{roj}\left(2R_{ange},0,0\right),P_{roj}\left(0,0,0\right)\right]$
$P_{roj}\left(2R_{ange},0,0\right)$
$\left[P_{roj}\left(-2R_{ange},0,0\right),P_{roj}\left(0,0,0\right)\right]$
$\left[P_{roj}\left(0,2R_{ange},0\right),P_{roj}\left(0,0,0\right)\right]$
$P_{roj}\left(0,2R_{ange},0\right)$
$\left[P_{roj}\left(0,-2R_{ange},0\right),P_{roj}\left(0,0,0\right)\right]$
$\left[P_{roj}\left(0,0,2R_{ange}\right),P_{roj}\left(0,0,0\right)\right]$
$P_{roj}\left(0,0,2R_{ange}\right)$
$\left[P_{roj}\left(0,0,-2R_{ange}\right),P_{roj}\left(0,0,0\right)\right]$
Project (x,y,z) as a Desmos point. Projection is done onto the x=0 plane.
$P_{roj}\left(x,y,z\right)=\left(M_{V2}\left(R,x,y,z\right),M_{V3}\left(R,x,y,z\right)\right)$
Vectors are rotated by matrix R before being projected onto the x=0 plane. Matrix R represents a rotation first about the z-axis then the y-axis.
$R=M_{M}\left(R_{Y}\left(\theta_{Y}\right),R_{Z}\left(\theta_{Z}\right)\right)$
Angles to rotate by before projection
$\theta_{Z}=1.02$
$\theta_{Y}=0.62$
Draggable point can never control rotation about x-axis.
$\left(2\theta_Z,-2\theta_Y\right)$
Matrix functions
Counterclockwise rotations of angle theta about the x, y and z axes respectively.
$R_{X}\left(\theta\right)=\left[1,0,0,0,\cos\left(\theta\right),-\sin\left(\theta\right),0,\sin\left(\theta\right),\cos\left(\theta\right)\right]$
$R_{Y}\left(\theta\right)=\left[\cos\left(\theta\right),0,\sin\left(\theta\right),0,1,0,-\sin\left(\theta\right),0,\cos\left(\theta\right)\right]$
$R_{Z}\left(\theta\right)=\left[\cos\left(\theta\right),-\sin\left(\theta\right),0,\sin\left(\theta\right),\cos\left(\theta\right),0,0,0,1\right]$
Return specific elements of the vector resulting from pre-multiplying vector v by 3x3 matrix m1.
$M_{V1}\left(m_1,v_1,v_2,v_3\right)=v_1m_1\left[1\right]+v_2m_1\left[2\right]+v_3m_1\left[3\right]$
$M_{V2}\left(m_{1},v_{1},v_{2},v_{3}\right)=v_{1}m_{1}\left[4\right]+v_{2}m_{1}\left[5\right]+v_{3}m_{1}\left[6\right]$
$M_{V3}\left(m_{1},v_{1},v_{2},v_{3}\right)=v_{1}m_{1}\left[7\right]+v_{2}m_{1}\left[8\right]+v_{3}m_{1}\left[9\right]$
Post-multiply matrix m1 by matrix m2.
$M_{M}\left(m_{1},m_{2}\right)=\left[\sum_{n=1}^{3}\left(m_{1}\left[n\right]m_{2}\left[3n-2\right]\right),\sum_{n=1}^{3}\left(m_{1}\left[n\right]m_{2}\left[3n-1\right]\right),\sum_{n=1}^{3}\left(m_{1}\left[n\right]m_{2}\left[3n\right]\right),\sum_{n=1}^{3}\left(m_{1}\left[n+3\right]m_{2}\left[3n-2\right]\right),\sum_{n=1}^{3}\left(m_{1}\left[n+3\right]m_{2}\left[3n-1\right]\right),\sum_{n=1}^{3}\left(m_{1}\left[n+3\right]m_{2}\left[3n\right]\right),\sum_{n=1}^{3}\left(m_{1}\left[n+6\right]m_{2}\left[3n-2\right]\right),\sum_{n=1}^{3}\left(m_{1}\left[n+6\right]m_{2}\left[3n-1\right]\right),\sum_{n=1}^{3}\left(m_{1}\left[n+6\right]m_{2}\left[3n\right]\right)\right]$
By Richard Zhang |
|