[英]Compute a RPY (roll pitch yaw) from a 3d point on a sphere
I need a method to find a set of homogenous transformation matrices that describes the position and orientation in a sphere.我需要一种方法来找到一组描述球体中位置和方向的齐次变换矩阵。
The idea is that I have an object in the center of this sphere which has a radius of dz.这个想法是我在这个球体的中心有一个物体,它的半径为 dz。 Since I know the 3d coordinate of the object I know all the 3d coordinates of the sphere.
因为我知道对象的 3d 坐标,所以我知道球体的所有 3d 坐标。 Is it possible to determine the RPY of any point on the sphere such that the point always points toward the object in the center?
是否可以确定球体上任何点的 RPY,使得该点始终指向中心的物体?
illustration:插图:
At the origo of this sphere we have an object.在这个球体的原点,我们有一个对象。 The radius of the sphere is dz.
球体的半径为 dz。 The red dot is a point on the sphere, and the vector from this point toward the object/origo.
红点是球体上的一个点,以及从这个点到物体/原点的向量。
The position should be relatively easy to extract, as a sphere can be described by a function, but how do I determine the vector, or rotation matrix that points such that it points toward origo.位置应该相对容易提取,因为一个球体可以用一个函数来描述,但是我如何确定指向原点的向量或旋转矩阵。
You could, using the center of the sphere as the origin, compute the unit vector of the line formed by the origin to the point on the edge of the sphere, and then multiply that unit vector by -1 to obtain the vector pointing toward the center of the sphere from the point on the edge of the sphere.您可以使用球体的中心作为原点,计算由原点到球体边缘上的点所形成的直线的单位向量,然后将该单位向量乘以 -1 以获得指向该点的向量从球体边缘的点到球体的中心。
Example:例子:
vec pointToCenter(Point edge, Point origin) {
vec norm = edge - origin;
vec unitVec = norm / vecLength(norm);
return unitVec * -1;
}
Once you have the vector you can convert it to euler angles for the RPY, an example is here一旦你有你可以将其转换为RPY欧拉角载体,一个例子是在这里
Of the top of my head I would suggest using quaterneons to define the rotation of any point at the origin, relative to the point you want on the surface of the sphere:在我的头顶,我建议使用四元数来定义原点处任何点的旋转,相对于球体表面上你想要的点:
I don't have time to write code for this but I wrote a little tutorial with compilable code examples in a github repository a while back, which should get you started:我没有时间为此编写代码,但不久前我在 github 存储库中编写了一个带有可编译代码示例的小教程,这应该可以帮助您入门:
https://github.com/brownwa/opengl https://github.com/brownwa/opengl
Do the mat_rotation tutorial first, then do the quatereons one.先做 mat_rotation 教程,然后做 quatereons 一。 It's doable in a weekend, a day if you're focused.
如果您专心,则可以在周末或一天内完成。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.