add project method to Vector2/3
This commit is contained in:
parent
af93842f93
commit
037f4638ab
7 changed files with 32 additions and 7 deletions
|
|
@ -109,6 +109,8 @@ 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 project(const Vector3 &p_b) const;
|
||||
|
||||
_FORCE_INLINE_ real_t angle_to(const Vector3 &p_b) const;
|
||||
|
||||
_FORCE_INLINE_ Vector3 slide(const Vector3 &p_normal) const;
|
||||
|
|
@ -238,6 +240,10 @@ real_t Vector3::distance_squared_to(const Vector3 &p_b) const {
|
|||
return (p_b - *this).length_squared();
|
||||
}
|
||||
|
||||
Vector3 Vector3::project(const Vector3 &p_b) const {
|
||||
return p_b * (dot(p_b) / p_b.dot(p_b));
|
||||
}
|
||||
|
||||
real_t Vector3::angle_to(const Vector3 &p_b) const {
|
||||
|
||||
return Math::atan2(cross(p_b).length(), dot(p_b));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue