Given a homogeneous 4x4 matrix, how can I get a 3D world?

So, I have an object that rotates, then translates and rotates again. I save the matrix of these translations as a member of the object. Now, when I come to the choice of an object, I need to know the three-dimensional world coordinates of this object.

Currently, I managed to get the position of the object so

coords[0] = finalMatrix[12];

coords[1] = finalMatrix[13];

coords[2] = finalMatrix[14];

This gives me the correct positions of the objects, but I also want to take them into account.

Any help would be great ...

+4
source share
3 answers

The matrix is ​​a 4x4 matrix, but since you only have one dimensional matrix, it seems that the elements are arranged as follows:

 [0] [4] [8] [12] [1] [5] [9] [13] [2] [6] [10] [14] [3] [7] [11] [15] 

The rotational part is the upper left 3x3 cm matrix here , so in your case it will be the elements [0]-[2] , [4]-[6] and [8]-[10]

+2
source

http://www.euclideanspace.com/maths/geometry/affine/matrix4x4/index.htm is an explanation of how 4x4 matrices work. The first minor 3x3 is the rotation matrix. The last column, except for the last element, is a translation vector. The element [4, 4] is large-scale. Read more about this link

+2
source

So, I'm an idiot ... I had it right in the first place. All I need is these provisions in [12] [13] [14]. I had some stupid mistakes in my code, one of which did not have enough iterations at my ray intersection ... All lol im sorted right now are kicking themselves .. Haha thanks to all the guys!

+1
source

Source: https://habr.com/ru/post/1336929/


All Articles