Simplify Transform2D get_rotation

This commit is contained in:
Aaron Franke 2020-06-17 00:57:09 -04:00
parent 02f7908d46
commit 0fa478a050
No known key found for this signature in database
GPG Key ID: 40A1750B977E56BF
1 changed files with 1 additions and 6 deletions

View File

@ -78,12 +78,7 @@ void Transform2D::set_skew(float p_angle) {
} }
real_t Transform2D::get_rotation() const { real_t Transform2D::get_rotation() const {
real_t det = basis_determinant(); return Math::atan2(elements[0].y, elements[0].x);
Transform2D m = orthonormalized();
if (det < 0) {
m.scale_basis(Size2(1, -1)); // convention to separate rotation and reflection for 2D is to absorb a flip along y into scaling.
}
return Math::atan2(m[0].y, m[0].x);
} }
void Transform2D::set_rotation(real_t p_rot) { void Transform2D::set_rotation(real_t p_rot) {