Package eu.svjatoslav.sixth.e3d.geometry
Class Polygon
java.lang.Object
eu.svjatoslav.sixth.e3d.geometry.Polygon
Utility class for polygon operations, primarily point-in-polygon testing.
Provides static methods for geometric computations on triangles and other polygons.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanpointWithinPolygon(Point2D point, Point2D p1, Point2D p2, Point2D p3) Tests whether a point lies inside a triangle using the ray-casting algorithm.
-
Constructor Details
-
Polygon
public Polygon()Creates a new Polygon utility instance.
-
-
Method Details
-
pointWithinPolygon
Tests whether a point lies inside a triangle using the ray-casting algorithm.This method casts a horizontal ray from the test point and counts intersections with the triangle edges. If the number of intersections is odd, the point is inside.
- Parameters:
point- the point to testp1- the first vertex of the trianglep2- the second vertex of the trianglep3- the third vertex of the triangle- Returns:
trueif the point is inside the triangle
-