CMAttitude and CATransform3D linked by rotational matrices?

I look at the CMAttitude basic motion CMAttitude , it can express the device orientation as a 3x3 rotation matrix. At the same time, I looked at CATransform3D , which encapsulates the attitude of the gaze as well as the scaling. CATransform3D is a 4x4 matrix.

I saw that the OpenGL rotation matrix is ​​4x4 and just 0001 is complemented by a fourth row and column.

Am I wandering if the CMAttitude rotation matrix is ​​related to the CATransform matrix?

Is it possible to use device rotation in the space obtained using the rotational matrix to convert the UIView using CATransform3D ? My intention is to let the user move the phone and apply it to the UIView on the screen.

Bonus question: if they are related, how do I convert the CMAttitude rotation matrix to CATransform3D?

+6
source share
1 answer

A gyroscope is used to determine only the orientation of the device in space. There are many ways to parameterize the orientation itself (see Information on SO (3) for theoretical information) - quaternions, Euler angles, and 3x3 matrices are one of them.

The "embedding" of a 3x3 matrix in a 4x4 matrix is ​​not a GL-specific trick. This is a “semi-direct product” of the translation group (which is isomorphic to all three-dimensional vectors) and the rotation group (of the SO (3) mentioned above).

To get the CATransform3D matrix from CMAttitude, you have to assume some position of your object. If it is zero, then just put the matrix with the number 0001, as you said.

This question may interest you: Apple Gyro Code Example

+4
source

Source: https://habr.com/ru/post/917210/


All Articles