轴角旋转向量如何工作以及它们与旋转矩阵相比如何? [英] How do axis-angle rotation vectors work and how do they compare to rotation matrices?

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

问题描述

我在理解在 3D 空间中旋转矢量时如何使用轴角旋转矢量时遇到了一些麻烦.为什么要使用这些以及这些与旋转矩阵有何关系?

我还发现了一个名为

在我们的例子中,向量 k 指向正上方,向量 v 指向西北 45 度角.我们希望将这个向量围绕由向量 k 定义的轴旋转 180 度角,所以如果你这样做,vrot 就是结果向量.v||v_|_v 相对于向量k 的平行和垂直投影.这些被证明可以推导出罗德里格斯公式,我不会在这里介绍.如果你想要一个完整的推导,我会给你参考这篇文章.

提出 Rodrigues 旋转公式来旋转物体的原因是因为非常频繁地,在某些应用中,您绕着不以原点为中心的轴旋转,也不是以原点为中心旋转相对于标准的 xyz 轴.

其实看维基百科的文章,是不需要转成矩阵形式来旋转东西的.你可以直接使用单位向量和旋转角度来旋转你的向量,这就引出了他的旋转公式:

来源:

如果你在上面的矩阵中替换theta = pi,你将得到与vrrot2vec2mat函数中看到的M相同的东西.然而,忽略第一行、第二列的符号,因为它是由于数值精度......这将我们引向第二个参数 options.基本上,当使用 Rodrigues 旋转公式计算旋转矩阵值时,有时矩阵中的值会非常小.options 结构有一个名为 epsilon 的字段,您可以在其中指定任何小于此阈值的值,在计算矩阵后将其视为零.1e-12 的默认值非常适合恕我直言.

如果您想更改默认的 epsilon,只需创建一个具有单个元素 epsilon 的结构,该元素会更改此阈值,并在这额外的一秒内调用该函数论点......所以像:

<代码>>>options.epsilon = 1e-15;>>M = vrrotvec2mat([0 0 1 pi], 选项);

<小时>

无论如何,回到我们之前讨论的内容,假设我们给定的向量 v 相对于上图并且指向西北 - 特别是 (x,y,z) = (1,0,1).如果我们使用这个旋转矩阵并旋转这个点,我们应该让它平行于 xz 平面并指向相反的方向,所以我们应该得到 (x,y,z) = (-1,0,1):

<代码>>>M*[1;0;1]答案 =-1.00000.00001.0000

<小时>

您也可以使用罗德里格斯旋转公式得到相同的结果:

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

<小时>

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

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?

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 explanations are very limited, as follows:

Convert rotation from axis-angle to matrix representation

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

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.

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).

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.

解决方案

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.

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.

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.

Here's a pictorial example I got from Wikipedia:

Source: Rodrigues' Rotation formula

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.

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.

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:

Source: Rodrigues' Rotation formula

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.

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.


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

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:

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.

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);


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


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


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天全站免登陆