How to use a 4x4 Matrix to translate a point in 3D space

Click For Summary
SUMMARY

This discussion focuses on using 4x4 matrices to translate and rotate points in 3D space, specifically for artistic applications. The user begins with a point at Cartesian coordinates (2, 1.5, 3) and a direction vector (1, 0, 0). They construct an initial state matrix (Matrix1) and a transformation matrix (Matrix2) for iterative transformations. Key points include the importance of using radians for angle θ in transformations, the process of multiplying matrices to derive new positions, and the distinction between column and row-major notation.

PREREQUISITES
  • Understanding of 4x4 matrix representation in 3D transformations
  • Familiarity with Cartesian coordinates and vector notation
  • Basic knowledge of trigonometric functions (sine and cosine)
  • Concept of projective geometry and its application in 3D space
NEXT STEPS
  • Learn about 3D transformation matrices and their applications in graphics programming
  • Study the differences between column-major and row-major matrix representations
  • Explore the implementation of iterative transformations in 3D graphics using libraries like OpenGL
  • Investigate the mathematical foundations of projective geometry and its relevance to computer graphics
USEFUL FOR

Artists, 3D modelers, and developers interested in understanding 3D transformations for graphics applications, as well as students studying linear algebra and projective geometry.

STENDEC
Messages
21
Reaction score
0
Hello, apologies in advance if my questions seem rather ignorant. I'm trying my best (and struggling) to understand the topic, but my background in math is weak, and i need the math for artistic purposes.

I want to iteratively move and rotate a point in 3D space (move, rotate, move, rotate...) and from what I understand multiplication of 4x4 matrices lends itself to the task. The point has a direction it's pointing in (necessary for such motion); I take it that makes it a vector?

Let's say the point's position (Cartesian coordinates) is (2, 1.5, 3)
And the direction it points in is (1, 0, 0)
From what I understand, I first create a matrix that represents the current state:

Matrix1=<br /> \begin{bmatrix} <br /> 0 &amp; 0 &amp; 0 &amp; 2 \\ <br /> 0 &amp; 0 &amp; 0 &amp; 1.5 \\ <br /> 0 &amp; 0 &amp; 0 &amp; 3 \\ <br /> 0 &amp; 0 &amp; 0 &amp; 1 \end{bmatrix}
Is this matrix ok (maybe missing 1's in the first 3 columns?) or have I fundamentally misunderstood something?Next I have to create a matrix that transforms the location and rotation of the point/vector. Through my online searches I found this:

Matrix2=<br /> \begin{bmatrix} <br /> tx^2+c &amp; txy-sz &amp; txz+sy &amp; X_{1} \\ <br /> txy+sz &amp; ty^2+c &amp; tyz-sx &amp; Y_{1} \\ <br /> txz-sy &amp; tyz-sx &amp; tz^2+c &amp; Z_{1} \\ <br /> 0 &amp; 0 &amp; 0 &amp; 1 \end{bmatrix}
Where:
X_{1}, Y_{1}, Z_{1} is the desired translation in Cartesian coordinates, e.g. 0, 0, 3.75 to move 3.75 units along the system's z axis.
x, y, z are the unit vector (1, 0, 0 in my case)
c = cosθ
s = sinθ
t = 1-cosθ

Is the angle θ in degrees or radians, can you tell from looking at its usage?

1. Once I have constructed Matrix2, do I multiply it by Matrix1 to derive a Matrix3 which contains the new position/direction of my point?

2. How would i go about retrieving the new Cartesian coordinates (position and rotation) from Matrix3?

3a. If Matrix2 contains my desired transformation, can i repeatedly multiply it with the result of a prior multiplication (M3'=M3xM2, M3=M3', M3'=M3xM2...) to achieve my original goal of iterative translation (most likely resulting in a circle or helix)?

3b. If i had to feed Matrix2 a unit vector, wouldn't what comes in from Matrix3' during the next iteration be unsuitable?Again, sorry if i expose gaping holes in my comprehension. I hope my intentions make some sense.

Thanks!
 
Last edited:
Physics news on Phys.org
This is an example of "projective geometry" in which we think of the set of all lines through the orgin in n-dimensional space as points in n-1 dimensional space.

Specifically, a line through the origin can be written x_1= a_1t, x_2= a_2t, ..., x_n= a_nt which we could represent as the vector equation &lt;x_1, x_2, ..., x_n&gt;= &lt;a_1, a_2, ..., a_n&gt;t. If we take s= zt as parameter instead of t, t= s/z so that becomes &lt;x_1, x_2, ..., x_n&gt;= &lt;a_1/a_n, a_2/a_n, ..., 1&gt;z which we can interpret as the point (a_1/a_n, a_2/a_n, ..., a_{n-1}/a_n, 1), in Rn-1, ignoring that last "1" but with the understanding that if any operation changes that last component, we immediately divide through by it to alway get 1.
In that way, we can represent a point (a, b, c) as the column matrix \begin{bmatrix}a \\ b\\ c\\ 1\end{bmatrix}.

Now, notice that the matrix multiplication
\begin{bmatrix}1 &amp; 0 &amp; 0 &amp; dx \\ 0 &amp; 1 &amp; 0 &amp; dy \\ 0 &amp; 0 &amp; 1 &amp; dz\\ 0 &amp; 0 &amp; 0 &amp; 1\end{bmatrix}\begin{bmatrix}a \\ b \\ c \\ 1\end{bmatrix}= \begin{bmatrix}a+ dx \\ b+ dy\\ c+ dz \\ 1\end{bmatrix}
gives the column matrix corresponding to the point (a+ dx, b+ dy, c+ dz).

If we were to replace the first three rows and columns by a "rotation matrix" we get both rotation and translation, giving all rigid motions in three dimensions, in a single matrix.
 
Last edited by a moderator:
Thank you HallsOfIvy! This has helped clarify some things for me and i got the first results in the right direction. It seems that among other things, i was confused about column vs row-major notation as well.

I saw that the homework & coursework section of this forum is also for "personal study" and thus probably better suited if i want extended assistance. I will prepare a new post there building on what i learned.
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 10 ·
Replies
10
Views
3K
Replies
4
Views
4K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
Replies
4
Views
2K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K