Black Trigram (흑괘) - Korean Martial Arts Combat Simulator API - v0.5.30
    Preparing search index...

    Function isPointInPolygon

    • Check if a point is inside a polygon using ray-casting algorithm

      Korean: 점-다각형 내부 확인 (Point-in-Polygon Test)

      Uses the ray-casting algorithm to determine if a point is inside a polygon. Casts a ray from the point to infinity and counts boundary crossings. Odd number of crossings = inside, even number = outside.

      Parameters

      • point: Position

        Position to test

      • polygon: readonly Position[]

        Array of positions defining polygon vertices

      Returns boolean

      true if point is inside polygon, false otherwise

      const polygon = [
      { x: 0, y: 0 },
      { x: 10, y: 0 },
      { x: 10, y: 10 },
      { x: 0, y: 10 }
      ];
      const inside = isPointInPolygon({ x: 5, y: 5 }, polygon); // true
      const outside = isPointInPolygon({ x: 15, y: 5 }, polygon); // false