[Scummvm-git-logs] scummvm master -> 881b477e833136d63b81f9c8b54456d395f5a8b1
aquadran
aquadran at gmail.com
Mon Oct 18 05:48:37 UTC 2021
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
881b477e83 MATH: Added length and interpolate helpers for Vector3d
Commit: 881b477e833136d63b81f9c8b54456d395f5a8b1
https://github.com/scummvm/scummvm/commit/881b477e833136d63b81f9c8b54456d395f5a8b1
Author: PaweÅ KoÅodziejski (aquadran at gmail.com)
Date: 2021-10-18T07:48:33+02:00
Commit Message:
MATH: Added length and interpolate helpers for Vector3d
Changed paths:
math/vector3d.h
diff --git a/math/vector3d.h b/math/vector3d.h
index e1e1f26ae6..ca9cf889fb 100644
--- a/math/vector3d.h
+++ b/math/vector3d.h
@@ -84,6 +84,33 @@ public:
inline static Angle angle(const Vector3d& v1, const Vector3d& v2) {
return Angle::arcCosine(fminf(fmaxf(dotProduct(v1, v2) / (v1.getMagnitude() * v2.getMagnitude()), -1.0f), 1.0f));
}
+
+ /**
+ * Calculate vector length
+ * @return The computed length
+ */
+ inline static float length(const Vector3d& v) {
+ return sqrtf(v.x() * v.x() + v.y() * v.y() + v.z() * v.z());
+ }
+
+ /**
+ * Calculate vector length
+ * @return The computed length
+ */
+ float length() {
+ return sqrtf(x() * x() + y() * y() + z() * z());
+ }
+
+ /**
+ * Linearly interpolate between two vectors
+ * @param v1 The first vector
+ * @param v2 The second vector
+ * @param a The value to use to interpolate between v1 and v2
+ * @return The resulting calculation
+ */
+ inline static Vector3d interpolate(const Vector3d& v1, const Vector3d& v2, const float a) {
+ return Vector3d(v1 * (1.0f - a) + v2 * a);
+ }
};
} // end of namespace Math
More information about the Scummvm-git-logs
mailing list