首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 其他相关 >

三维中的旋转-旋转向量

2012-12-23 
三维空间中的旋转--旋转向量 处理三维旋转问题时,通常采用旋转矩阵的方式来描述。一个向量乘以旋转矩阵等价

三维空间中的旋转--旋转向量

 

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


OpenCV实现Rodrigues变换的函数为

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

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

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

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


旋转向量的物理意义为:

 

三维中的旋转-旋转向量A visualization of a rotation represented by an Euler axis and angle., 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 (itsscalar 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;
    doubler_vec[3]={-2.100418,-2.167796,0.273330};
    doubleR_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]);
    }
}

 

,三维中的旋转-旋转向量, 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).

,三维中的旋转-旋转向量 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 , called arotation 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

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 i2 = ?1
The determinant ofA 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. Theeigenvector 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 3Dorthonormal 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.

三维中的旋转-旋转向量A visualization of a rotation represented by an Euler axis and angle., 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 (itsscalar 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.

三维中的旋转-旋转向量Euler rotations of the Earth. Intrinsic (green), Precession (blue) and Nutation (red)

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 thehypercomplex numbers satisfying

三维中的旋转-旋转向量

Quaternion multiplication is performed in the same manner as multiplication ofcomplex 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 theinverse 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 errorsThe quaternion elements vary continuously over the unit sphere in 三维中的旋转-旋转向量, (denoted by三维中的旋转-旋转向量) as the orientation changes, avoidingdiscontinuous jumps (inherent to three-dimensional parameterizations)Expression of the rotation matrix in terms of quaternion parameters involves notrigonometric functionsIt 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

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

where the symbol 三维中的旋转-旋转向量 denotes theouter product. This product of vectors三维中的旋转-旋转向量 produces two terms: a scalar part from the inner product and abivector 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 theimaginary unit. Geometric algebra uses bivectors in its analogue to the quaternion, therotor, given by 三维中的旋转-旋转向量, where 三维中的旋转-旋转向量 is a unit bivector that describes theplane of rotation. Because 三维中的旋转-旋转向量 squares to ?1, thepower series expansion of三维中的旋转-旋转向量 generates thetrigonometric functions. The rotation formula that maps a vector 三维中的旋转-旋转向量 to a rotated vector三维中的旋转-旋转向量 is then

三维中的旋转-旋转向量

where 三维中的旋转-旋转向量 is thereverse 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 anymultivector. 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.

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 thequadrant that the point 三维中的旋转-旋转向量 is in; seeatan2.

When implementing the conversion, one has to take into account several situations: 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 thex-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.

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 theRodrigues' rotation formula (with appropriate modification) as follows:

三维中的旋转-旋转向量

with 三维中的旋转-旋转向量 the

is the cross-product matrix.

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:

The rotation matrix corresponding to the quaternion 三维中的旋转-旋转向量 can be computed as follows:

三维中的旋转-旋转向量

with 三维中的旋转-旋转向量 the

which gives

三维中的旋转-旋转向量

or equivalently

三维中的旋转-旋转向量
from the Euler angles三维中的旋转-旋转向量 as follows:

三维中的旋转-旋转向量

Given the rotation quaternion 三维中的旋转-旋转向量, the x-convention 3-1-3 Euler angles三维中的旋转-旋转向量 can be computed by

三维中的旋转-旋转向量
and angle三维中的旋转-旋转向量, the quaternion

三维中的旋转-旋转向量

can be computed by

三维中的旋转-旋转向量

Given the rotation quaternion 三维中的旋转-旋转向量, define三维中的旋转-旋转向量. Then the Euler axis三维中的旋转-旋转向量 and angle三维中的旋转-旋转向量 can be computed by

三维中的旋转-旋转向量
can be extracted from the derivative of the rotation matrix 三维中的旋转-旋转向量 by the following relation:

三维中的旋转-旋转向量

The derivation is adapted from 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

三维中的旋转-旋转向量 (seecircular motion andCross product).

By the transitivity of the above mentioned equations,

三维中的旋转-旋转向量

which implies (Q.E.D.),

三维中的旋转-旋转向量
can be obtained from the derivative of the quaternion三维中的旋转-旋转向量 as follows

where 三维中的旋转-旋转向量 is the inverse of三维中的旋转-旋转向量.


Conversely, the derivative of the quaternion is

三维中的旋转-旋转向量

热点排行