What are the pros and cons of using Matrices, Eule

2019-02-05 04:41发布

Matrices and Euler angles can suffer from Gimbal lock but what are some other arguments for using one over the other?

What do you think DirectX favors?

What do you use in daily C++/C/DirectX programming?

4条回答
Anthone
2楼-- · 2019-02-05 04:48

Euler Angles suffer from singularities and are difficult to work with. Matrix representations DO NOT have that problem contrary to a number of answers here. A matrix representation of orientation can suffer from accumulated errors because you're using 9 numbers for something that only has 3 degrees of freedom. Quaternions are very interesting mathematically, but at the end of the day they're really doing a 4x4 matrix multiply.

A quaternion can also be seen as a 3vec that represents a rotation axis and its length is related to the angle of rotation about that axis (sin squared?). The 4th parameter is computed to make the length of the 4vec equal to 1. This interpretation can be converted to an equivalent orientation matrix.

Matrix representation can include scaling information, and can be extended to 4x4 to include position information as well as orientation. You can transform both position and direction vectors using the matrix transform which is not possible using the other two.

You can do an incredible amount of stuff very simply with a 4x4 matrix. Quaternions and Euler angles just do orientation. Yeah, just that one thing. I guess my preference/bias on this issue is rather clear :-)

查看更多
放荡不羁爱自由
3楼-- · 2019-02-05 04:55

Quaternions are by far the hardest to master, but once you understand what they're about you'll find them surprisingly easy to use. I consider them to be a better solution then Euler Angles/Matrix transforms because they deal with a problem that the other 2 solutions don't. The "Gimball lock".

查看更多
手持菜刀,她持情操
4楼-- · 2019-02-05 04:56

It's not really related to directx. You can use either method, but arguably quaternions are easier to deal with for animation data. Otherwise you don't have a single standard way to deal with it and therefore it makes it harder to interpret data across programs.

查看更多
forever°为你锁心
5楼-- · 2019-02-05 05:02

Euler angles only require three parameters, as opposed to storing a matrix (or three, but that sounds excessive). When you apply the Euler rotation, however, you will possibly end up with something equivalent to three matrix multiplications to create the transformation. If you were only using a matrix, you might not incur such an expensive cost (depending on how the matrix was constructed). Besides Gimbal Lock, there is also a problem with cancellation effects when interpolating matrix representations of rotations that you need to be careful about.

You might want to consider quaternions. They require four parameters of storage, so they are not very heavy. They avoid Gimbal lock and can be interpolated for rendering smooth rotations. One thing that can be interpreted as a downside for the quaternion is that they may not be very intuitive for some. Matrix transformations and Euler angles have a type of roll-yaw-pitch or spin-precession-nutation that is pretty intuitive. Quaternions are more akin to a single rotation about some end-result axis sticking out this or that way.

There are probably cases where someone would prefer one method over the others, so these are just some things to consider when making a decision.

查看更多
登录 后发表回答