处理三维旋转问题时,通常采用旋转矩阵的方式来描述。一个向量乘以旋转矩阵等价于向量以某种方式进行旋转。除了采用旋转矩阵描述外,还可以用旋转向量来描述旋转,旋转向量的长度(模)表示绕轴逆时针旋转的角度(弧度)。旋转向量与旋转矩阵可以通过罗德里格斯(Rodrigues)变换进行转换。

OpenCV实现Rodrigues变换的函数为

int cvRodrigues2( const CvMat* src, CvMat* dst, CvMat* jacobian=0 );

src为输入的旋转向量(3x1或者1x3)或者旋转矩阵(3x3)。

dst为输出的旋转矩阵(3x3)或者旋转向量(3x1或者1x3)。

jacobian为可选的输出雅可比矩阵(3x9或者9x3),是输入与输出数组的偏导数。

旋转向量的物理意义为:

Euler axis and angle (rotation vector)

A visualization of a rotation represented by an Euler axis and angle.

Main article: Axis angle

From Euler's rotation theorem we know that any rotation can be expressed as a single rotation about some axis. The axis is the unit vector (unique except for sign) which remains unchanged by the rotation. The magnitude of the angle is also unique, with its sign being determined by the sign of the rotation axis.

The axis can be represented as a three-dimensional unit vector , and the angle by a scalar .

Since the axis is normalized, it has only two degrees of freedom. The angle adds the third degree of freedom to this rotation representation.

One may wish to express rotation as a rotation vector, a non-normalized three-dimensional vector the direction of which specifies the axis, and the length of which is :

The rotation vector is in some contexts useful, as it represents a three-dimensional rotation with only three scalar values (its scalar components), representing the three degrees of freedom. This is also true for representations based on sequences of three Euler angles (see below).

If the rotation angle is zero, the axis is not uniquely defined. Combining two successive rotations, each represented by an Euler axis and angle, is not straightforward, and in fact does not satisfy the law of vector addition, which shows that finite rotations are not really vectors at all. It is best to employ the rotation matrix or quaternion notation, calculate the product, and then convert back to Euler axis and angle.

验证代码如下:

#include <stdio.h>
#include <cv.h>

void main()
{
    int i;
    double r_vec[3]={-2.100418,-2.167796,0.273330};
    double R_matrix[9];
    CvMat pr_vec;
    CvMat pR_matrix;

cvInitMatHeader(&pr_vec,1,3,CV_64FC1,r_vec,CV_AUTOSTEP);
    cvInitMatHeader(&pR_matrix,3,3,CV_64FC1,R_matrix,CV_AUTOSTEP);
    cvRodrigues2(&pr_vec, &pR_matrix,0);

for(i=0; i<9; i++)
    {
        printf("%f\n",R_matrix[i]);
    }
}

Rotation formalisms in three dimensions

From Wikipedia, the free encyclopedia
Jump to: navigation, search

In geometry, various formalisms exist to express a rotation in three dimensions as a mathematical transformation. In physics, this concept extends to classical mechanics where rotational (or angular) kinematics is the science of describing with numbers the purely rotational motion of an object.

According to Euler's rotation theorem the general displacement of a rigid body (or three-dimensional coordinate system) with one point fixed is described by a rotation about some axis. This allows the use of rotations to express orientations as a single rotation from a reference placement in space of the rigid body (or coordinate system). Furthermore, such a rotation may be uniquely described by a minimum of three parameters. However, for various reasons, there are several ways to represent it. Many of these representations use more than the necessary minimum of three parameters, although each of them still has only three degrees of freedom.

An example where rotation representation is used is in computer vision, where an automated observer needs to track a target. Let's consider a rigid body, with an orthogonal right-handed triad , , and of unit vectors fixed to its body (representing the three axes of the object's coordinate system). The basic problem is to specify the orientation of this triad, and hence the rigid body, in terms of the reference coordinate system (in our case the observer's coordinate system).

Contents

[hide]

  • 1 Rotation matrix
  • 2 Euler axis and angle (rotation vector)
  • 3 Euler rotations
  • 4 Quaternions
  • 5 Rodrigues parameters
  • 6 Cayley–Klein parameters
  • 7 Higher dimensional analogues
  • 8 Rotors in a geometric algebra
  • 9 Conversion formulae between formalisms
    • 9.1 Rotation matrix ↔ Euler angles
    • 9.2 Rotation matrix ↔ Euler axis/angle
    • 9.3 Rotation matrix ↔ quaternion
    • 9.4 Euler angles ↔ quaternion
    • 9.5 Euler axis/angle ↔ quaternion
  • 10 Conversion formulae between derivatives
    • 10.1 Rotation matrix ↔ angular velocities
    • 10.2 Quaternion ↔ angular velocities
  • 11 See also
  • 12 References
  • 13 External links

[edit] Rotation matrix

Main article: Rotation matrix

The above mentioned triad of unit vectors is also called a basis. Specifying the coordinates (scalar components) of this basis in its current (rotated) position, in terms of the reference (non-rotated) coordinate axes, will completely describe the rotation. The three unit vectors , and which form the rotated basis each consist of 3 coordinates, yielding a total of 9 parameters. These parameters can be written as the elements of a 3 × 3 matrix , called a rotation matrix. Typically, the coordinates of each of these vectors are arranged along a column of the matrix (however, beware that an alternative definition of rotation matrix exists and is widely used, where the vectors coordinates defined above are arranged by rows[1])

The elements of the rotation matrix are not all independent – as Euler's rotation theorem dictates, the rotation matrix has only three degrees of freedom. The rotation matrix has the following properties:

  • A is a real, orthogonal matrix, hence each of its rows or columns represents a unit vector.
  • The eigenvalues of A are
where i is the standard imaginary unit with the property i 2 = −1
  • The determinant of A is +1, equivalent to the product of its eigenvalues.
  • The trace of A is , equivalent to the sum of its eigenvalues.

The angle which appears in the eigenvalue expression corresponds to the angle of the Euler axis and angle representation. The eigenvector corresponding with the eigenvalue of 1 is the accompanying Euler axis, since the axis is the only (nonzero) vector which remains unchanged by left-multiplying (rotating) it with the rotation matrix.

The above properties are equivalent to:

which is another way of stating that form a 3D orthonormal basis. Note that the statements above constitute a total of 6 conditions (the cross product contains 3), leaving the rotation matrix with just 3 degrees of freedom as required.

Two successive rotations represented by matrices and are easily combined as follows: (Note the order, since the vector being rotated is multiplied from the right). The ease by which vectors can be rotated using a rotation matrix, as well as the ease of combining successive rotations, make the rotation matrix a very useful and popular way to represent rotations, even though it is less concise than other representations.

[edit] Euler axis and angle (rotation vector)

A visualization of a rotation represented by an Euler axis and angle.

Main article: Axis angle

From Euler's rotation theorem we know that any rotation can be expressed as a single rotation about some axis. The axis is the unit vector (unique except for sign) which remains unchanged by the rotation. The magnitude of the angle is also unique, with its sign being determined by the sign of the rotation axis.

The axis can be represented as a three-dimensional unit vector , and the angle by a scalar .

Since the axis is normalized, it has only two degrees of freedom. The angle adds the third degree of freedom to this rotation representation.

One may wish to express rotation as a rotation vector, a non-normalized three-dimensional vector the direction of which specifies the axis, and the length of which is :

The rotation vector is in some contexts useful, as it represents a three-dimensional rotation with only three scalar values (its scalar components), representing the three degrees of freedom. This is also true for representations based on sequences of three Euler angles (see below).

If the rotation angle is zero, the axis is not uniquely defined. Combining two successive rotations, each represented by an Euler axis and angle, is not straightforward, and in fact does not satisfy the law of vector addition, which shows that finite rotations are not really vectors at all. It is best to employ the rotation matrix or quaternion notation, calculate the product, and then convert back to Euler axis and angle.

[edit] Euler rotations

Euler rotations of the Earth. Intrinsic (green), Precession (blue) and Nutation (red)

Main article: Euler angles#Euler rotations

The idea behind Euler rotations is to split the complete rotation of the coordinate system into three simpler constitutive rotations, called Precession, Nutation, and intrinsic rotation, being each one of them an increment on one of the Euler angles. Notice that the outer matrix will represent a rotation around one of the axes of the reference frame, and the inner matrix represents a rotation around one of the moving frame axis. The middle matrix represent a rotation around an intermediate axis called line of nodes.

Unfortunately, the definition of Euler angles is not unique and in the literature many different conventions are used. These conventions depend on the axes about which the rotations are carried out, and their sequence (since rotations are not commutative).

The convention being used is usually indicated by specifying the axes about which the consecutive rotations (before being composed) take place, referring to them by index (1, 2, 3) or letter (X, Y, Z). The engineering and robotics communities typically use 3-1-3 Euler angles. Notice that after composing the independent rotations, they do not rotate about their axis anymore. The most external matrix rotates the other two, leaving the second rotation matrix over the line of nodes, and the third one in a frame comoving with the body. There are 3×3×3 = 27 possible combinations of three basic rotations but only 3×2×2 = 12 of them can be used for representing arbitrary 3D rotations as Euler angles. These 12 combinations avoid consecutive rotations around the same axis (such as XXY) which would reduce the degrees of freedom that can be represented.

Therefore Euler angles are never expressed in terms of the external frame, or in terms of the co-moving rotated body frame, but in a mixture. Other conventions (e.g., rotation matrix or quaternions) are used to avoid this problem.

[edit] Quaternions

Main article: Quaternions and spatial rotation

Quaternions (Euler symmetric parameters) have proven very useful in representing rotations due to several advantages above the other representations mentioned in this article.

A quaternion representation of rotation is written as a normalized four-dimensional vector

In terms of the Euler axis

and angle

this vector's elements are expressed as follows:

The above definition follows the convention as used in (Wertz 1980) and (Markley 2003). An alternative definition used in some publications defines the "scalar" term as the first quaternion element, with the other elements shifted down one position. (Coutsias 1999), (Schmidt 2001)

Inspection shows that the quaternion parametrization obeys the following constraint:

The last term (in our definition) is often called the scalar term, which has its origin in quaternions when understood as the mathematical extension of the complex numbers, written as

with

and where are the hypercomplex numbers satisfying

Quaternion multiplication is performed in the same manner as multiplication of complex numbers, except that the order of elements must be taken into account, since multiplication is not commutative. In matrix notation we can write quaternion multiplication as

Combining two consecutive quaternion rotations is therefore just as simple as using the rotation matrix. Remember that two successive rotation matrices, followed by , are combined as follows:

We can represent this quaternion parameters in a similarly concise way. Please note the inverse ordering of quaternion multiplication when compared to matrix multiplication.

Quaternions are a very popular parametrization due to the following properties:

  • More compact than the matrix representation and less susceptible to round-off errors
  • The quaternion elements vary continuously over the unit sphere in , (denoted by ) as the orientation changes, avoiding discontinuous jumps (inherent to three-dimensional parameterizations)
  • Expression of the rotation matrix in terms of quaternion parameters involves no trigonometric functions
  • It is simple to combine two individual rotations represented as quaternions using a quaternion product

Like rotation matrices, quaternions must sometimes be re-normalized due to rounding errors, to make sure that they correspond to valid rotations. The computational cost of re-normalizing a quaternion, however, is much less than for normalizing a 3 × 3 matrix.

[edit] Rodrigues parameters

Main article: Euler–Rodrigues parameters
See also: Rodrigues' rotation formula

Rodrigues parameters can be expressed in terms of Euler axis and angle as follows:

This has a discontinuity at 180° (π radians): each vector, r, with a norm of π radians represent the same rotation as −r.

Similarly, the Gibbs representation can be expressed as follows:

A rotation g followed by a rotation f in Gibbs representation has the form

The Gibbs vector has the advantage (or disadvantage, depending on context) that 180° rotations cannot be represented. (Even using floating point numbers that include infinity, rotation direction cannot be well-defined; for example, naively a 180° rotation about the axis (1, 1, 0) would be , which is the same representation as 180° rotation about (1, 0.0001, 0).)

Modified Rodrigues parameters (MRPs) can be expressed in terms of Euler axis and angle by:

The modified Rodrigues parameterization shares many characteristics with the rotation vector parametrization, including the occurrence of discontinuous jumps in the parameter space when incrementing the rotation.

[edit] Cayley–Klein parameters

See definition at Wolfram Mathworld

[edit] Higher dimensional analogues

See also: Rotations in 4-dimensional Euclidean space

[edit] Rotors in a geometric algebra

The formalism of geometric algebra (GA) provides an extension and interpretation of the quaternion method. Central to GA is the geometric product of vectors, an extension of the traditional inner and cross products, given by

where the symbol denotes the outer product. This product of vectors produces two terms: a scalar part from the inner product and a bivector part from the outer product. This bivector describes the plane perpendicular to what the cross product of the vectors would return.

Bivectors in GA have some unusual properties compared to vectors. Under the geometric product, bivectors have negative square: the bivector describes the -plane. Its square is . Because the unit basis vectors are orthogonal to each other, the geometric product reduces to the antisymmetric outer product – and can be swapped freely at the cost of a factor of −1. The square reduces to since the basis vectors themselves square to +1.

This result holds generally for all bivectors, and as a result the bivector plays a role similar to the imaginary unit. Geometric algebra uses bivectors in its analogue to the quaternion, the rotor, given by , where is a unit bivector that describes the plane of rotation. Because squares to −1, the power series expansion of generates the trigonometric functions. The rotation formula that maps a vector to a rotated vector is then

where is the reverse of (reversing the order of the vectors in is equivalent to changing its sign).

Example. A rotation about the axis can be accomplished by converting to its dual bivector, , where is the unit volume element, the only trivector (pseudoscalar) in three-dimensional space. The result is . In three-dimensional space, however, it is often simpler to leave the expression for , using the fact that commutes with all objects in 3D and also squares to −1. A rotation of the vector in this plane by an angle is then

Recognizing that and that is the reflection of about the plane perpendicular to gives a geometric interpretation to the rotation operation: the rotation preserves the components that are parallel to and changes only those that are perpendicular. The terms are then computed:

The result of the rotation is then

A simple check on this result is the angle . Such a rotation should map the to . Indeed, the rotation reduces to

exactly as expected. This rotation formula is valid not only for vectors but for any multivector. In addition, when Euler angles are used, the complexity of the operation is much reduced. Compounded rotations come from multiplying the rotors, so the total rotor from Euler angles is

but and . These rotors come back out of the exponentials like so:

where refers to rotation in the original coordinates. Similarly for the rotation, . Noting that and commute (rotations in the same plane must commute), and the total rotor becomes

Thus, the compounded rotations of Euler angles become a series of equivalent rotations in the original fixed frame.

While rotors in geometric algebra work almost identically to quaternions in three dimensions, the power of this formalism is its generality: this method is appropriate and valid in spaces with any number of dimensions. In 3D, rotations have three degrees of freedom, a degree for each linearly independent plane (bivector) the rotation can take place in. It has been known that pairs of quaternions can be used to generate rotations in 4D, yielding six degrees of freedom, and the geometric algebra approach verifies this result: in 4D, there are six linearly independent bivectors that can be used as the generators of rotations.

[edit] Conversion formulae between formalisms

It has been suggested that Rotation matrix#Conversions be merged into this article or section. (Discuss) Proposed since October 2009.

[edit] Rotation matrix ↔ Euler angles

The Euler angles can be extracted from the rotation matrix by inspecting the rotation matrix in analytical form.

Using the x-convention, the 3-1-3 Euler angles , and (around the , and again the -axis) can be obtained as follows:

Note that is equivalent to where it also takes into account the quadrant that the point is in; see atan2.

When implementing the conversion, one has to take into account several situations:[2]

  • There are generally two solutions in (−π, π]3 interval. The above formula works only when is from the interval [0, π)3.
  • For special case , shall be derived from .
  • There is infinitely many but countably many solutions outside of interval (−π, π]3.
  • Whether all mathematical solutions apply for given application depends on the situation.

The rotation matrix is generated from the Euler angles by multiplying the three matrices generated by rotations about the axes.

The axes of the rotation depend on the specific convention being used. For the x-convention the rotations are about the , and axes with angles , and , the individual matrices are as follows:

This yields

Note: This is valid for a right-hand system, which is the convention used in almost all engineering and physics disciplines.

[edit] Rotation matrix ↔ Euler axis/angle

If the Euler angle is not a multiple of , the Euler axis and angle can be computed from the elements of the rotation matrix as follows:

Alternatively, the following method can be used:

Eigen-decomposition of the rotation matrix yields the eigenvalues 1, and . The Euler axis is the eigenvector corresponding to the eigenvalue of 1, and the can be computed from the remaining eigenvalues.

The Euler axis can be also found using Singular Value Decomposition since it is the normalized vector spanning the null-space of the matrix .

To convert the other way the rotation matrix corresponding to an Euler axis and angle can be computed according to the Rodrigues' rotation formula (with appropriate modification) as follows:

with the 3 × 3 identity matrix, and

is the cross-product matrix.

[edit] Rotation matrix ↔ quaternion

When computing a quaternion from the rotation matrix there is a sign ambiguity, since and represent the same rotation.

One way of computing the quaternion from the rotation matrix is as follows:

There are three other mathematically equivalent ways to compute . Numerical inaccuracy can be reduced by avoiding situations in which the denominator is close to zero. One of the other three methods looks as follows:[3]

The rotation matrix corresponding to the quaternion can be computed as follows:

with the 3 × 3 identity matrix, and

which gives

or equivalently

[edit] Euler angles ↔ quaternion

Main article: Conversion between quaternions and Euler angles

We will consider the x-convention 3-1-3 Euler Angles for the following algorithm. The terms of the algorithm depend on the convention used.

We can compute the quaternion from the Euler angles as follows:

Given the rotation quaternion , the x-convention 3-1-3 Euler angles can be computed by

[edit] Euler axis/angle ↔ quaternion

Given the Euler axis and angle , the quaternion

can be computed by

Given the rotation quaternion , define . Then the Euler axis and angle can be computed by

[edit] Conversion formulae between derivatives

[edit] Rotation matrix ↔ angular velocities

The angular velocity vector can be extracted from the derivative of the rotation matrix by the following relation:

The derivation is adapted from [4] as follows:

For any vector consider and differentiate it:

The derivative of a vector is the linear velocity of its tip. Since A is a rotation matrix, by definition the length of is always equal to the length of , and hence it does not change with time. Thus, when rotates, its tip moves along a circle, and the linear velocity of its tip is tangential to the circle; i.e., always perpendicular to . In this specific case, the relationship between the linear velocity vector and the angular velocity vector is

(see circular motion and Cross product).

By the transitivity of the above mentioned equations,

which implies (Q.E.D.),

[edit] Quaternion ↔ angular velocities

The angular velocity vector can be obtained from the derivative of the quaternion as follows[5]:

where is the inverse of .

Conversely, the derivative of the quaternion is

三维空间中的旋转--旋转向量相关推荐

  1. 三维空间中两次旋转等效为一次旋转的计算方法(四元数)

    首先介绍一下四元数: 四元数是一种高阶复数,其形式如下: H = s p a n { 1 , i , j , k } \mathbb{H} = span\{1,i,j,k\} H=span{1,i,j ...

  2. 2d的公式_旋转之二 - 三维空间中的旋转:罗德里格旋转公式

    接上篇: 复数与2D旋转 先来推导三维空间中的常用旋转公式. 三维空间中的旋转 如果 绕着空间中的一个单位向量 旋转,旋转我们采用右手坐标系: 可以把 分解成平行于 的向量 和 : 绕 旋转并不会造成 ...

  3. 三维空间中曲线绕任意轴旋转所得的旋转曲面求法

    三维空间中曲线绕任意轴旋转所得的旋转曲面求法 对2023汤家凤考研高等数学讲义225页2.三维空间直线旋转曲面的解释和推广 ©️ sylvanding

  4. 求解三维空间中两向量之间的夹角

    问题描述:已知三维空间中的三个点P1P_1P1​,P2P_2P2​和P3P_3P3​,求向量P1P2→\overrightarrow{P_1P_2}P1​P2​​和P1P3→\overrightarr ...

  5. 坐标系旋转与向量旋转(旋转矩阵)

    二维坐标系旋转与向量(坐标)旋转 坐标系的旋转和向量的旋转在工程应用过程中经常会遇到,在这里对二维坐标系的旋转和向量旋转做一个简单的推导,方便大家的理解. 坐标系旋转 一个平面坐标系逆时针旋转一个角度 ...

  6. UE4中物体的旋转位移方法总结大全

    一:UE4中物体的旋转 在开始之前我要介绍一些准备知识. 如下图所示: 在空间变换中物体的旋转有三个情况: 分别对应X轴旋转,Y轴旋转,Z轴旋转,对应起来就是roll, pitch, yaw. 以飞机 ...

  7. ai如何旋转画布_ai中怎么使用旋转工具制作旋转对称图?ai中使用旋转工具制作旋转对称图的方法...

    ai是一款可以在线编辑的位图软件,你知道ai中怎么使用旋转工具制作旋转对称图的吗?接下来我们一起往下看看ai中使用旋转工具制作旋转对称图的方法吧. 方法步骤 1.我们需要先打开ai软件,按ctrl+N ...

  8. 向量叉乘求三维空间中两直线(或线段)的交点

    1.2D空间的直线相交 在二维空间中,利用两个直线方程y = kx + b我们可以直接计算出交点,但是这种方法麻烦了些,并且套用到三维空间用公式就更麻烦了,接下来介绍的是如何利用向量叉乘求出直线交点. ...

  9. cad立体图怎么旋转看图_cad布局中图形怎么旋转

    在布局里面经常会用到很多命令.那么大家知道cad布局中图形怎么旋转吗?下面是学习啦小编整理的cad布局中图形怎么旋转的方法,希望能给大家解答. cad布局中图形旋转的方法一 小编在模型里面打开一张ca ...

  10. matlab因子载荷矩阵正交旋转,因素分析中的矩阵旋转

    因素分析中的矩阵旋转 因素分析法 因素分析是一种统计技术,目的是从众多的可观测的"变量"中,概括和推论少数"因素".用最少数的"因素"来概括 ...

最新文章

  1. 解读 2018 之运维篇:我们离高效智能的运维还有多远
  2. BenchmarkDotNet的使用
  3. mongodb 初次查询慢 加载索引
  4. 文巾解题 178. 分数排名
  5. 进程间通信:管道和命名管道(FIFO)
  6. fread rb与r,wb,w的区别
  7. 【C语言】一堆数组中存放了10个小于100的整数,请编程对所有数据按照从小到大的顺序进行排序,若个位数相等,则按照十位从小到大的顺序排序,输出排序后的结果...
  8. 决策树算法总结(下:CART决策树)
  9. 多元函数极值及其求法
  10. Python使用 opencv对CT图进行医学处理
  11. selenium与firefox、 chrome版本对应关系
  12. 程序员学习时间的由来
  13. 优质的凉亭 亭子 亭台ps后期素材素材推荐,不容错过
  14. 脸上不同位置长痘痘的原因
  15. 刷酸记录(迪维维A酸乳膏)20190905
  16. ClickHouse 基本语法(一)
  17. 银行外汇资金业务学习笔记(2)当我们在说头寸(position)的时候
  18. record sound
  19. Java基础语法-条件语句
  20. EMD经验模态分解——分析时间序列

热门文章

  1. 手机连接电脑服务器未响应怎么解决办法,电脑DNS服务器未响应怎么处理呢?
  2. SASE(什么是SASE)
  3. Uniqlo与Fast Retailing发出警告 46万消费者账号遭入侵
  4. 前端兼容性问题解决方案
  5. 公众号 自动生成海报 python_Python 生成公众号头图 1.0
  6. 介绍一种Android 平台 不需要获取imei imsi 无权限就能获取手机运营商的方法
  7. 计算机网络之:网段与IP地址
  8. ABBYY FineReader 14之如何选择正确的OCR选项
  9. Postfix 邮件服务 - roundcube webmail
  10. java // for // 俄文字母表