Merge pull request #27452 from Chaosus/direction_to
Added method to retrieve a direction vector from one point to another
This commit is contained in:
commit
7f3373d79f
7 changed files with 46 additions and 0 deletions
|
|
@ -132,6 +132,11 @@ namespace Godot
|
|||
(-p0 + 3.0f * p1 - 3.0f * p2 + p3) * t3);
|
||||
}
|
||||
|
||||
public Vector2 DirectionTo(Vector2 b)
|
||||
{
|
||||
return new Vector2(b.x - x, b.y - y).Normalized();
|
||||
}
|
||||
|
||||
public real_t DistanceSquaredTo(Vector2 to)
|
||||
{
|
||||
return (x - to.x) * (x - to.x) + (y - to.y) * (y - to.y);
|
||||
|
|
|
|||
|
|
@ -126,6 +126,11 @@ namespace Godot
|
|||
);
|
||||
}
|
||||
|
||||
public Vector3 DirectionTo(Vector3 b)
|
||||
{
|
||||
return new Vector3(b.x - x, b.y - y, b.z - z).Normalized();
|
||||
}
|
||||
|
||||
public real_t DistanceSquaredTo(Vector3 b)
|
||||
{
|
||||
return (b - this).LengthSquared();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue