summaryrefslogtreecommitdiff
path: root/core/math/vector3.h
diff options
context:
space:
mode:
Diffstat (limited to 'core/math/vector3.h')
-rw-r--r--core/math/vector3.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/core/math/vector3.h b/core/math/vector3.h
index 959f7cd0a8..d2f2408829 100644
--- a/core/math/vector3.h
+++ b/core/math/vector3.h
@@ -111,6 +111,12 @@ struct Vector3 {
_FORCE_INLINE_ real_t distance_to(const Vector3& p_b) const;
_FORCE_INLINE_ real_t distance_squared_to(const Vector3& p_b) const;
+
+
+ _FORCE_INLINE_ Vector3 slide(const Vector3& p_vec) const;
+ _FORCE_INLINE_ Vector3 reflect(const Vector3& p_vec) const;
+
+
/* Operators */
_FORCE_INLINE_ Vector3& operator+=(const Vector3& p_v);
@@ -368,6 +374,16 @@ void Vector3::zero() {
x=y=z=0;
}
+Vector3 Vector3::slide(const Vector3& p_vec) const {
+
+ return p_vec - *this * this->dot(p_vec);
+}
+Vector3 Vector3::reflect(const Vector3& p_vec) const {
+
+ return p_vec - *this * this->dot(p_vec) * 2.0;
+
+}
+
#endif
#endif // VECTOR3_H