Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'intern/moto/include/MT_Matrix3x3.h')
-rw-r--r--intern/moto/include/MT_Matrix3x3.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/intern/moto/include/MT_Matrix3x3.h b/intern/moto/include/MT_Matrix3x3.h
index 3197103a267..899a2731588 100644
--- a/intern/moto/include/MT_Matrix3x3.h
+++ b/intern/moto/include/MT_Matrix3x3.h
@@ -144,6 +144,26 @@ public:
-sj, cj * si, cj * ci);
}
+ void getEuler(MT_Scalar& yaw, MT_Scalar& pitch, MT_Scalar& roll) const
+ {
+ if (m_el[2][0] != -1.0 && m_el[2][0] != 1.0) {
+ pitch = MT_Scalar(-asin(m_el[2][0]));
+ yaw = MT_Scalar(atan2(m_el[2][1] / cos(pitch), m_el[2][2] / cos(pitch)));
+ roll = MT_Scalar(atan2(m_el[1][0] / cos(pitch), m_el[0][0] / cos(pitch)));
+ }
+ else {
+ roll = MT_Scalar(0);
+ if (m_el[2][0] == -1.0) {
+ pitch = MT_PI / 2.0;
+ yaw = MT_Scalar(atan2(m_el[0][1], m_el[0][2]));
+ }
+ else {
+ pitch = - MT_PI / 2.0;
+ yaw = MT_Scalar(atan2(m_el[0][1], m_el[0][2]));
+ }
+ }
+ }
+
void scale(MT_Scalar x, MT_Scalar y, MT_Scalar z) {
m_el[0][0] *= x; m_el[0][1] *= y; m_el[0][2] *= z;
m_el[1][0] *= x; m_el[1][1] *= y; m_el[1][2] *= z;