在另一个坐标系中查找点的坐标

Find coordinates of point in another coordinate system

我已经为这个非常简单的问题苦苦挣扎了很长时间,但我似乎无法理解如何去做。

我有两个坐标系。每一个在原点、比例、旋转方面都不同于另一个。我必须在另一个坐标系上找到任何随机点的 x、y、z 坐标。本质上是基础的改变。坐标系是这样构建的:

glm::mat4 matA = glm::mat4(); //Build matrix with identity
matA = matA*rotationA;     //Rotate
matA = matA*translationA;  //Translate


glm::mat4 matB = glm::mat4(); //Build matrix with identity
matB = matB*rotationB;     //Rotate
matB = matB*translationB;  //Translate

vec3 pointOnMatA = vec3( 5, 5, 5 );
//Find this point but on the matrixB coordinate system
vec3 pointOnMatB = ???

就数学而言应该是

pointOnMatB = matB*(inverseMatA*pointOnMatA);

至于评论中提出的问题:我不熟悉 glm,但矩阵向量乘法要求所有分量的顺序相同(mat4vec4)。 如果您使用的是 openGL 和齐次坐标系,则向量的前三个元素是 X、Y、Z,最后一个分量 (W) 应该是 1。这里有一个读物:

http://www.tomdalling.com/blog/modern-opengl/explaining-homogenous-coordinates-and-projective-geometry/

一个点在不同坐标系之间的坐标转换的思路是,首先找到对齐坐标系的变换,然后对这个点应用相同的变换。例如,如果我们有两个坐标系 A 和 B,并且我们有一个点,其坐标在坐标系 A 中给出,找到使坐标系 B 与 A 对齐的变换,然后对该点应用相同的变换并获得该点的坐标在坐标系 B.