summaryrefslogtreecommitdiff
path: root/core/math/matrix3.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/math/matrix3.cpp')
-rw-r--r--core/math/matrix3.cpp52
1 files changed, 5 insertions, 47 deletions
diff --git a/core/math/matrix3.cpp b/core/math/matrix3.cpp
index f2f6ff93cf..57555bbb2a 100644
--- a/core/math/matrix3.cpp
+++ b/core/math/matrix3.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -254,17 +254,6 @@ Vector3 Basis::get_scale() const {
Vector3(elements[0][2], elements[1][2], elements[2][2]).length());
}
-// Sets scaling while preserving rotation.
-// This requires some care when working with matrices with negative determinant,
-// since we're using a particular convention for "polar" decomposition in get_scale and get_rotation.
-// For details, see the explanation in get_scale.
-void Basis::set_scale(const Vector3 &p_scale) {
- Vector3 e = get_euler();
- Basis(); // reset to identity
- scale(p_scale);
- rotate(e);
-}
-
// Multiplies the matrix from left by the rotation matrix: M -> R.M
// Note that this does *not* rotate the matrix itself.
//
@@ -316,28 +305,6 @@ void Basis::get_rotation_axis_angle(Vector3 &p_axis, real_t &p_angle) const {
m.get_axis_angle(p_axis, p_angle);
}
-// Sets rotation while preserving scaling.
-// This requires some care when working with matrices with negative determinant,
-// since we're using a particular convention for "polar" decomposition in get_scale and get_rotation.
-// For details, see the explanation in get_scale.
-void Basis::set_rotation_euler(const Vector3 &p_euler) {
- Vector3 s = get_scale();
- Basis(); // reset to identity
- scale(s);
- rotate(p_euler);
-}
-
-// Sets rotation while preserving scaling.
-// This requires some care when working with matrices with negative determinant,
-// since we're using a particular convention for "polar" decomposition in get_scale and get_rotation.
-// For details, see the explanation in get_scale.
-void Basis::set_rotation_axis_angle(const Vector3 &p_axis, real_t p_angle) {
- Vector3 s = get_scale();
- Basis(); // reset to identity
- scale(s);
- rotate(p_axis, p_angle);
-}
-
// get_euler_xyz returns a vector containing the Euler angles in the format
// (a1,a2,a3), where a3 is the angle of the first rotation, and a1 is the last
// (following the convention they are commonly defined in the literature).
@@ -365,14 +332,10 @@ Vector3 Basis::get_euler_xyz() const {
if (euler.y < Math_PI * 0.5) {
if (euler.y > -Math_PI * 0.5) {
//if rotation is Y-only, return a proper -pi,pi range like in x or z for the same case.
- if (elements[1][0] == 0.0 && elements[0][1] == 0.0 && elements[0][0] < 0.0) {
+ if (elements[1][0] == 0.0 && elements[0][1] == 0.0 && elements[1][2] == 0 && elements[2][1] == 0 && elements[1][1] == 1) {
euler.x = 0;
+ euler.y = atan2(elements[0][2], elements[0][0]);
euler.z = 0;
-
- if (euler.y > 0.0)
- euler.y = Math_PI - euler.y;
- else
- euler.y = -(Math_PI + euler.y);
} else {
euler.x = Math::atan2(-elements[1][2], elements[2][2]);
euler.z = Math::atan2(-elements[0][1], elements[0][0]);
@@ -436,15 +399,10 @@ Vector3 Basis::get_euler_yxz() const {
if (m12 < 1) {
if (m12 > -1) {
- if (elements[1][0] == 0 && elements[0][1] == 0 && elements[2][2] < 0) { // use pure x rotation
- real_t x = asin(-m12);
+ if (elements[1][0] == 0 && elements[0][1] == 0 && elements[0][2] == 0 && elements[2][0] == 0 && elements[0][0] == 1) { // use pure x rotation
+ euler.x = atan2(-m12, elements[1][1]);
euler.y = 0;
euler.z = 0;
-
- if (x > 0.0)
- euler.x = Math_PI - x;
- else
- euler.x = -(Math_PI + x);
} else {
euler.x = asin(-m12);
euler.y = atan2(elements[0][2], elements[2][2]);