mirror of
https://github.com/godotengine/godot.git
synced 2024-11-27 09:16:35 +08:00
Merge pull request #21240 from aaronfranke/mono-project-vector
[Mono] Vector2/3 Project methods
This commit is contained in:
commit
1e729630d6
@ -122,7 +122,7 @@ Vector2 Vector2::rotated(real_t p_by) const {
|
||||
}
|
||||
|
||||
Vector2 Vector2::project(const Vector2 &p_b) const {
|
||||
return p_b * (dot(p_b) / p_b.dot(p_b));
|
||||
return p_b * (dot(p_b) / p_b.length_squared());
|
||||
}
|
||||
|
||||
Vector2 Vector2::snapped(const Vector2 &p_by) const {
|
||||
|
@ -241,7 +241,7 @@ real_t Vector3::distance_squared_to(const Vector3 &p_b) const {
|
||||
}
|
||||
|
||||
Vector3 Vector3::project(const Vector3 &p_b) const {
|
||||
return p_b * (dot(p_b) / p_b.dot(p_b));
|
||||
return p_b * (dot(p_b) / p_b.length_squared());
|
||||
}
|
||||
|
||||
real_t Vector3::angle_to(const Vector3 &p_b) const {
|
||||
|
@ -184,6 +184,11 @@ namespace Godot
|
||||
return result;
|
||||
}
|
||||
|
||||
public Vector2 Project(Vector2 onNormal)
|
||||
{
|
||||
return onNormal * (Dot(onNormal) / onNormal.LengthSquared());
|
||||
}
|
||||
|
||||
public Vector2 Reflect(Vector2 n)
|
||||
{
|
||||
return 2.0f * n * Dot(n) - this;
|
||||
|
@ -210,6 +210,11 @@ namespace Godot
|
||||
);
|
||||
}
|
||||
|
||||
public Vector3 Project(Vector3 onNormal)
|
||||
{
|
||||
return onNormal * (Dot(onNormal) / onNormal.LengthSquared());
|
||||
}
|
||||
|
||||
public Vector3 Reflect(Vector3 n)
|
||||
{
|
||||
#if DEBUG
|
||||
|
Loading…
Reference in New Issue
Block a user