Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ ClosestPointOnLineSegment()

static Vector2 Terraria.Physics.BallCollision.ClosestPointOnLineSegment ( Vector2 point,
LineSegment lineSegment )
inlinestaticprivate

Definition at line 364 of file BallCollision.cs.

365 {
366 Vector2 value = point - lineSegment.Start;
367 Vector2 vector = lineSegment.End - lineSegment.Start;
368 float num = vector.LengthSquared();
369 float num2 = Vector2.Dot(value, vector) / num;
370 if (num2 < 0f)
371 {
372 return lineSegment.Start;
373 }
374 if (num2 > 1f)
375 {
376 return lineSegment.End;
377 }
378 return lineSegment.Start + vector * num2;
379 }
static float Dot(Vector2 value1, Vector2 value2)
Definition Vector2.cs:121

References Microsoft.Xna.Framework.Vector2.Dot(), Terraria.DataStructures.LineSegment.End, Microsoft.Xna.Framework.Vector2.LengthSquared(), Terraria.DataStructures.LineSegment.Start, and System.value.

Referenced by Terraria.Physics.BallCollision.GetCollisionPointForTile().