Project/02 - Engine/LittleBigEngine/Utils/DouglasPeucker.cs
/// <summary>
/// The distance of a Vector2 from a line made from Vector21 and Vector22.
/// </summary>
/// <param name="pt1">The PT1.</param>
/// <param name="pt2">The PT2.</param>
/// <param name="p">The p.</param>
/// <returns></returns>
The distance of a Vector2 from a line made from Vector21 and Vector22.
The distance of a Vector2 from a line made from Vector21 and Vector22 .
public static Double PerpendicularDistance
            (Vector2 Vector21, Vector2 Vector22, Vector2 Vector2)
        {
            Double area = Math.Abs(.5 * (Vector21.X * Vector22.Y + Vector22.X *
            Vector2.Y + Vector2.X * Vector21.Y - Vector22.X * Vector21.Y - Vector2.X *
            Vector22.Y - Vector21.X * Vector2.Y));
            Double bottom = Math.Sqrt(Math.Pow(Vector21.X - Vector22.X, 2) +
            Math.Pow(Vector21.Y - Vector22.Y, 2));
            Double height = area / bottom * 2;
            return height;
        }
public static Double PerpendicularDistance ( Vector2 Vector21 , Vector2 Vector22 , Vector2 Vector2 ) { Double area = Math . Abs ( .5 * ( Vector21 . X * Vector22 . Y + Vector22 . X * Vector2 . Y + Vector2 . X * Vector21 . Y - Vector22 . X * Vector21 . Y - Vector2 . X * Vector22 . Y - Vector21 . X * Vector2 . Y ) ) ; Double bottom = Math . Sqrt ( Math . Pow ( Vector21 . X - Vector22 . X , 2 ) + Math . Pow ( Vector21 . Y - Vector22 . Y , 2 ) ) ; Double height = area / bottom * 2 ; return height ; }
The distance of a Vector2 from a line made from Vector21 and Vector22.
The distance of a Vector2 from a line made from Vector21 and Vector22 .
None
Vector21
Vector2
Vector22
Vector2
Vector2
Vector2
pt1
None
pt2
None
p
None