summaryrefslogtreecommitdiff
path: root/core/math
diff options
context:
space:
mode:
Diffstat (limited to 'core/math')
-rw-r--r--core/math/math_2d.cpp6
-rw-r--r--core/math/math_2d.h3
2 files changed, 8 insertions, 1 deletions
diff --git a/core/math/math_2d.cpp b/core/math/math_2d.cpp
index acaaa327f3..6c160abaca 100644
--- a/core/math/math_2d.cpp
+++ b/core/math/math_2d.cpp
@@ -74,7 +74,7 @@ float Vector2::distance_squared_to(const Vector2& p_vector2) const {
float Vector2::angle_to(const Vector2& p_vector2) const {
- return Math::atan2( x-p_vector2.x, y - p_vector2.y );
+ return Math::atan2( tangent().dot(p_vector2), dot(p_vector2) );
}
float Vector2::dot(const Vector2& p_other) const {
@@ -594,6 +594,10 @@ Matrix32 Matrix32::rotated(float p_phi) const {
}
+float Matrix32::basis_determinant() const {
+
+ return elements[0].x * elements[1].y - elements[0].y * elements[1].x;
+}
Matrix32 Matrix32::interpolate_with(const Matrix32& p_transform, float p_c) const {
diff --git a/core/math/math_2d.h b/core/math/math_2d.h
index 2c8749f79d..3cc5bdc843 100644
--- a/core/math/math_2d.h
+++ b/core/math/math_2d.h
@@ -553,6 +553,9 @@ struct Matrix32 {
void scale_basis(const Vector2& p_scale);
void translate( real_t p_tx, real_t p_ty);
void translate( const Vector2& p_translation );
+
+ float basis_determinant() const;
+
Vector2 get_scale() const;
_FORCE_INLINE_ const Vector2& get_origin() const { return elements[2]; }