轴角旋转矢量如何工作?如何与旋转矩阵进行比较? [英] How do axis-angle rotation vectors work and how do they compare to rotation matrices?

查看:191
本文介绍了轴角旋转矢量如何工作?如何与旋转矩阵进行比较?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在理解在3D空间中旋转矢量时如何使用轴角旋转矢量时,我有些麻烦.为什么要使用它们,它们与旋转矩阵有何关系?

I'm having a bit of trouble understanding how axis-angle rotation vectors are used when rotating a vector in 3D space. Why are these used and how do these relate to rotation matrices?

我还发现了一个名为 vrrotvec2mat 的函数,该函数似乎在做什么我想要但我不理解文档.具体来说,有人可以对输入参数roptions给出更清晰的解释(带有示例)吗?

I also found a function called vrrotvec2mat that seems to do what I want but I can't understand the documentation. Specifically, can someone give a more clear explanation (with some example) of the input arguments r and options?

MathWorks的解释非常有限,如下所示:

MathWorks explanations are very limited, as follows:

将旋转角度从轴角度转换为矩阵表示形式

Convert rotation from axis-angle to matrix representation

m = vrrotvec2mat(r)返回由轴角旋转矢量r定义的旋转的矩阵表示.

m = vrrotvec2mat(r) returns a matrix representation of the rotation defined by the axis-angle rotation vector, r.

m = vrrotvec2mat(r,options)返回由轴角旋转矢量r定义的旋转矩阵表示,默认算法参数由options中定义的值代替.

m = vrrotvec2mat(r,options) returns a matrix representation of rotation defined by the axis-angle rotation vector r, with the default algorithm parameters replaced by values defined in options.

选项结构包含参数epsilon,该参数表示一个值,低于该值将被视为零(默认值为1e-12).

The options structure contains the parameter epsilon that represents the value below which a number will be treated as zero (default value is 1e-12).

旋转向量r是四个元素的行向量,其中前三个元素指定旋转轴,最后一个元素定义角度.

The rotation vector, r, is a row vector of four elements, where the first three elements specify the rotation axis, and the last element defines the angle.

要旋转三个元素的列向量,请将其乘以旋转矩阵. >要旋转三个元素的行向量,请将其乘以转置的旋转矩阵.

To rotate a column vector of three elements, multiply it by the rotation matrix. >To rotate a row vector of three elements, multiply it by the transposed rotation matrix.

推荐答案

如果您想了解vrrotvec2mat函数,则在我们深入研究此函数之前,需要了解旋转的轴角表示方式是如何工作的.具体来说,您是在了解 Rodrigues旋转公式,也称为轴角旋转公式.我将首先通过一些介绍向您解释.

If you want to understand the vrrotvec2mat function, you need to know how axis-angle representations of rotations work before we delve into this function. Specifically, you're looking at understanding the Rodrigues Rotation formula, which is also known as the axis-angle rotation formula. I'll explain this to you with some introduction first.

在线性代数中,旋转点(无论是2D还是3D)的最标准方法是使用旋转矩阵,您可以在其中乘以该旋转矩阵的2D或3D坐标(即y = A*x其中x是您在列向量中表示的点).这使点围绕坐标系的原点旋转.您也可以将其视为旋转 vector v,其中尾巴位于原点,头部位于2D或3D空间中的点.

In Linear Algebra, the most standard way to rotate a point, whether it's 2D or 3D is to use a rotation matrix where you pre-multiply (i.e. y = A*x where x is your point represented in a column vector) the 2D or 3D coordinate with this rotation matrix. This rotates the point around the origin of the coordinate system. You can also think of this as rotating a vector v where the tail is at the origin and the head is at the point in 2D or 3D space.

但是,另一种方法是提供称为 axis-angle 的表示,该表示仅在3D空间中有效.该轴由单位矢量k描述,单位矢量k通过

However, another way to do this is to provide what is known as the axis-angle representation which is only valid in 3D space. The axis is described by a unit vector k that describes an axis of rotation about which the vector v rotates by an angle around this axis by the right-hand rule.

这是我从Wikipedia获得的图片示例:

Here's a pictorial example I got from Wikipedia:

来源:罗德里格斯的旋转公式

在我们的例子中,向量k指向正上方,向量v指向西北45度角.我们希望将此向量围绕向量k定义的轴旋转180度,因此,如果执行此操作,则vrot是结果向量. v||v_|_v相对于矢量k的平行和垂直投影.这些都显示出了Rodrigues公式,在这里我将不介绍它.如果您需要完整的推论,请参考这篇文章.

The vector k in our case is pointing straight up and the vector v is pointing on a 45 degree angle northwest. We wish to rotate this vector by an angle of 180 degrees around the axis defined by the vector k, and so if you do this, vrot is the resulting vector. v|| and v_|_ are the parallel and perpendicular projections of v with respect to the vector k. These are shown to derive the Rodrigues formula, which I won't go through here. I'll refer you to the article if you want a full derivation.

之所以建议使用Rodrigues旋转公式来旋转物体,是因为在很多应用中,您绕着不以原点为中心的轴旋转,或者不随相对于标准xyz轴.

The reason why the Rodrigues rotation formula was proposed to rotate things is because very frequently, there are applications where you are rotating about an axis that is not centred at the origin, nor are you rotating with respect to a standard x,y and z axis.

实际上,如果您查看Wikipedia文章,则无需转换为矩阵形式即可旋转事物.您可以直接使用单位矢量和旋转角度来旋转矢量,这将导致我们得出其旋转公式:

In fact, if you look at the Wikipedia article, you don't need to convert to the matrix form to rotate things. You can use the unit vector and rotation angle directly to rotate your vector, which leads us to his rotation formula:

来源:罗德里格斯的旋转公式

之所以存在vrrotvec2mat,是因为您可以在旋转矢量的轴角表示和相对于线性代数中的原点旋转的旋转矩阵之间进行转换.然后,您可以应用相同的线性代数理论在给定旋转矩阵的情况下在3D空间中旋转矢量/点.您可以分别使用vrrotvec2matvrrotmat2vec在法向旋转矩阵和Rodrigues公式表示形式之间来回转换.

The reason why vrrotvec2mat exists is because you can convert between the axis-angle representation of rotating a vector and a rotation matrix with a rotation with respect to the origin in Linear Algebra. You can then apply the same Linear Algebra theory to rotate a vector/point in 3D space given this rotation matrix. You can convert back and forth between a normal rotation matrix and the Rodrigues formula representation by using vrrotvec2mat and vrrotmat2vec respectively.

轴角表示本质上是一个4元素向量,其中前三个元素是定义您的旋转轴的单位向量kxyz分量,最后一个元素是相对于此轴旋转矢量的旋转角度theta. vrrotvec2mat在这里没有什么不同,并且按照我刚才所说的顺序,它需要一个4元素向量.但是,快速查看源代码后,theta的弧度定义为 .

The axis-angle representation is essentially a 4 element vector where the first three elements are the x,y and z components of the unit vector k that defines your rotation axis and the last element is the rotation angle theta that rotates your vector with respect to this axis. vrrotvec2mat is no different here and requires a 4 element vector in the order that I just talked about. However, having a quick look at the source, theta is defined in radians.

如果您想要查看此作品的具体示例,让我们以上图为例.单位矢量kz轴上指向上方,因此前三个分量为(0,0,1).我们希望旋转180度,所以第四个参数是pi ...等等:

If you want a concrete example of seeing this work, let's use the above diagram as an example. The unit vector k is pointing upwards on the z axis, and so the first three components are (0,0,1). We wish to rotate by 180 degrees, and so the fourth argument is pi... and so:

>> M = vrrotvec2mat([0 0 1 pi])

M =

   -1.0000   -0.0000         0
    0.0000   -1.0000         0
         0         0    1.0000

如果您看一看笛卡尔空间中围绕z轴的标准旋转矩阵,则它精确地定义了围绕z轴的180度旋转.如果您还记得旋转矩阵,则为:

This exactly defines a rotation of 180 degrees around the z-axis if you take a look at the standard rotation matrix in Cartesian space around the z axis. If you recall the rotation matrix for this, it's:

如果在上面的矩阵中替换theta = pi,将得到与M相同的功能,如vrrot2vec2mat函数所示.但是,由于数值精度的缘故,请忽略第一行,第二列的符号,这将导致我们进入第二个参数options.基本上,当使用Rodrigues旋转公式计算旋转矩阵值时,有时矩阵中的值会很小. options结构具有一个名为epsilon的字段,您可以在其中指定小于该阈值的任何值,然后在计算矩阵后将其视为零. 1e-12的默认值非常适合恕我直言.

If you substitute theta = pi in the above matrix, you will get the same thing as M as seen in the vrrot2vec2mat function. However, ignore the sign of the first row, second column as it's due to numerical precision... which leads us to the second parameter options. Basically, when computing the rotation matrix values using the Rodrigues Rotation formula, there will be times where values in the matrix will be quite small. The options structure has a field called epsilon, where you can specify anything smaller than this threshold is considered zero after the matrix has been calculated. The default of 1e-12 is quite suitable IMHO.

如果您想更改默认的epsilon,只需创建一个具有单个元素epsilon的结构即可更改此阈值,然后使用此第二个附加参数调用该函数...类似这样:

If you'd like to change the default epsilon, simply create a structure that has a single element epsilon that changes this threshold and call the function with this additional second argument... so something like:

>> options.epsilon = 1e-15;
>> M = vrrotvec2mat([0 0 1 pi], options);


无论如何,回到我们在说什么,让我们说给定的矢量v是关于上图的,它指向西北-特别是(x,y,z) = (1,0,1).如果使用此旋转矩阵并旋转此点,则应使其平行于xz平面并指向相反的方向,因此应获取(x,y,z) = (-1,0,1):


In any case, going back to what we were talking about, let's say our given vector v is with respect to the above figure and that it's pointing northwest - specifically at (x,y,z) = (1,0,1). If we use this rotation matrix and rotate this point, we should get it to be parallel to the xz plane and pointing in the opposite direction, and so we should get (x,y,z) = (-1,0,1):

>> M*[1;0;1]

ans =

   -1.0000
    0.0000
    1.0000


您还可以使用Rodrigues旋转公式获得相同的结果:


You can also get the same result by using the Rodrigues Rotation formula:

>> v = [1;0;1];
>> k = [0;0;1];
>> theta = pi;
>> vrot = v*cos(theta) + cross(k,v)*sin(theta) + k*(k.'*v)*(1-cos(theta))

vrot =

   -1.0000
    0.0000
    1.0000


总而言之,这是围绕任意轴旋转矢量的另一种方式,而不仅限于标准xyz.


All in all, it's just another way of rotating a vector around an arbitrary axis, not just limited to the standard x, y or z.

这篇关于轴角旋转矢量如何工作?如何与旋转矩阵进行比较?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆