Convert other forms to Euler angle form

1. The direction of the axis of the coordinate system

The left-handed coordinate system is agreed in the 3D mathematical foundation

  

                         Left-handed coordinate system Right-handed coordinate system

Left-hand positive direction: +x positive pans right, +y pans upwards, +z pans forwards.

Right-hand positive direction: +x translates to the left, +y translates up, and +z translates forward.

2. Three commonly used coordinate systems

2.1 World coordinate system

The largest coordinate system of interest, used to describe other coordinate systems.

 

 2.2 Object coordinate system

With itself as the origin, its own coordinate system, the camera coordinate system belongs to the object coordinate system.

  That is, the z-axis (the forward direction) is inward, and many other books such as visual SLAM are in the right-handed coordinate system, and the z-axis is outward.

 2.3 Inertial coordinate system

There is an inertial coordinate system between the previous world coordinate system and the object coordinate system.

 The meaning of the transformation from the object coordinate system to the world coordinate system: For example, if the mobile phone is 3 meters in front of you (described by the object coordinate system centered on you), where is the mobile phone in this room? (This room is the world coordinate system)

So how to represent rotation? The three representations described below: matrix, Euler angle, quaternion.

3. Matrix

 A matrix is ​​used to transform a vector from one coordinate system to another, and the rotation matrix describes the relative displacement between the two coordinate systems. A 4x4 matrix contains a 3x3 rotation part and a 1x3 translation part.

 Because the last column is always [0,0,0,1]^T, it is removed and becomes a 4x3 matrix, which has rotation and translation functions.

4. Euler angles

Euler angles indicate that rotation is to split the rotation into rotations around any three mutually perpendicular axes. The three axes can be used in any order, but the commonly used ones are as follows. 

toward tilt roll
3D Math Foundation heading pitch bank
Vision SLAM 14 yaw pitch roll
Axis of rotation around the object coordinate system y x z

    

        heading is the amount of rotation around the y-axis of the object coordinate system, and pitch is the amount of rotation around the x-axis of the object coordinate system

      Bank is the amount of rotation around the z-axis of the object coordinate system

For example, a car on the road only rotates around the y-axis of the object coordinate system, that is, only heading.

5. Quaternions

A quaternion contains a scalar w and a 3D vector v, represented as:

[w, v] or

[w, (x,y,z)]

For example, the quaternion

 

/
//
// 3D Math Primer for Games and Graphics Development
//
// EulerAngles.h - Declarations for class EulerAngles
//
// Visit gamemath.com for the latest version of this file.
//
// For more details, see EulerAngles.cpp
//
/

#ifndef __EULERANGLES_H_INCLUDED__
#define __EULERANGLES_H_INCLUDED__

// Forward declarations  预声明

class Quaternion;
class Matrix4x3;
class RotationMatrix;

// 以欧拉角形式保存方位
//---------------------------------------------------------------------------
// class EulerAngles
//
// This class represents a heading-pitch-bank Euler angle triple.

class EulerAngles {
public:

// Public data

	// Straightforward representation.  直接的表示方式
    // Store the three angles, in radians 弧度表示

	float	heading;  // heading,pitch,bank (朝向,倾斜,翻滚)
	float	pitch;
	float	bank;

// Public operations

	// 1,Default constructor does nothing

	EulerAngles() {}

	// Construct from three values

	EulerAngles(float h, float p, float b) :
		heading(h), pitch(p), bank(b) {}

	// Set to identity triple (all zeros)
    //2,单位欧拉角
	void	identity() { heading = pitch = bank = 0.0f; }

	// Determine "canonical" Euler angle triple
    //3,声明限制的欧拉角:pitch倾斜限制在-90,90之间
	void	canonize();

	// Convert the quaternion to Euler angle format.  
    // The input quaternion is assumed to perform the rotation from object-to-inertial
	// or inertial-to-object, as indicated.
    // 3, 两个函数功能:四元数转欧拉角形式
	void	fromObjectToInertialQuaternion(const Quaternion &q);  // 输入四元数参数作用:物体坐标转惯性坐标
	void	fromInertialToObjectQuaternion(const Quaternion &q);  // 

	// Convert the transform matrix to Euler angle format.  
    // The input matrix is assumed to perform the transformation from object-to-world, 
    // or world-to-object, as indicated.  
    // The translation portion of the matrix is ignored.  The matrix is assumed to be orthogonal(正交矩阵).
    // 4,两个函数功能:转换矩阵转欧拉角形式
	void	fromObjectToWorldMatrix(const Matrix4x3 &m);  // 输入四元数参数作用:物体坐标转世界坐标
	void	fromWorldToObjectMatrix(const Matrix4x3 &m);

	// Convert a rotation matrix to Euler Angle form.
    // 5,函数功能:旋转矩阵转欧拉角形式
	void	fromRotationMatrix(const RotationMatrix &m);
};

// A global "identity" Euler angle constant
// 全局单位欧拉角常量
extern const EulerAngles kEulerAnglesIdentity;

/
#endif // #ifndef __EULERANGLES_H_INCLUDED__

to be continued. . .

Guess you like

Origin blog.csdn.net/jizhidexiaoming/article/details/131748368