summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorMarc <marc.gilleron@gmail.com>2020-12-08 20:00:06 +0000
committerGitHub <noreply@github.com>2020-12-08 20:00:06 +0000
commit43828ebb3931b9117ad57f08cc457e052fdfd631 (patch)
treede8de890bf0a7fed5d6bd3b717bd76eb681d9809 /include
parent1ec4526c1d908e58e896e8b4ce71bc4ee4c7452a (diff)
parent96ae052e06efc24c02f184e07f21c1213c02e4db (diff)
downloadredot-cpp-43828ebb3931b9117ad57f08cc457e052fdfd631.tar.gz
Merge pull request #459 from Silver1063/master
Added some missing Vector3 functions and Fixed Vector3 slide
Diffstat (limited to 'include')
-rw-r--r--include/core/Vector3.hpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/include/core/Vector3.hpp b/include/core/Vector3.hpp
index d879097..5971787 100644
--- a/include/core/Vector3.hpp
+++ b/include/core/Vector3.hpp
@@ -165,6 +165,11 @@ struct Vector3 {
z + (p_t * (p_b.z - z)));
}
+ inline Vector3 slerp(const Vector3 &p_b, real_t p_t) const {
+ real_t theta = angle_to(p_b);
+ return rotated(cross(p_b).normalized(), theta * p_t);
+ }
+
Vector3 cubic_interpolate(const Vector3 &b, const Vector3 &pre_a, const Vector3 &post_b, const real_t t) const;
Vector3 move_toward(const Vector3 &p_to, const real_t p_delta) const {
@@ -206,6 +211,10 @@ struct Vector3 {
return x * b.x + y * b.y + z * b.z;
}
+ inline Vector3 project(const Vector3 &p_b) const {
+ return p_b * (dot(p_b) / p_b.length_squared());
+ }
+
inline real_t angle_to(const Vector3 &b) const {
return std::atan2(cross(b).length(), dot(b));
}
@@ -264,7 +273,7 @@ struct Vector3 {
void rotate(const Vector3 &p_axis, real_t p_phi);
inline Vector3 slide(const Vector3 &by) const {
- return by - *this * this->dot(by);
+ return *this - by * this->dot(by);
}
void snap(real_t p_val);