Controls

Drag points on the canvas or edit coordinates below.

V₀
V₁
V₂
V₃

Query Point

Q
INSIDE
Q = (2, 3)

Problem

Bearcu membuat sebuah kebun madu rahasia berbentuk pagar tertutup dengan n tiang penanda. Ia perlu mengklasifikasikan setiap sarang lebah yang ditemukan di berbagai lokasi:

  • Di dalam batas kebun → INSIDE
  • Di luar batas kebun → OUTSIDE
  • Tepat di atas pagar batas → BOUNDARY

Algorithm

Boundary check: For each edge, compute orientation with cross product. If collinear and on-segment → BOUNDARY.

Ray casting: Cast a horizontal ray to the right from Q. Count edge crossings (odd = inside, even = outside). Uses cross product to avoid floating-point division.

Canvas

-10-10-5-5551010V₀V₁V₂V₃Q (2, 3)