Package org.alban098.physics2j
Class Polygon
java.lang.Object
org.alban098.physics2j.Polygon
The
Polygon
class encapsulates a description of a closed, two-dimensional region within a
coordinate space. This region is bounded by an arbitrary number of line segments, each of which
is one side of the polygon. Internally, a polygon comprises of a list of (x,y)
coordinate
pairs, where each pair defines a vertex of the polygon, and two successive pairs are the
endpoints of a line that is a side of the polygon. The first and final pairs of (x,y)
points are joined by a line segment that closes the polygon. This Polygon
is defined with
an even-odd winding rule. See WIND_EVEN_ODD
for
a definition of the even-odd winding rule. This class's hit-testing methods, which include the
contains
, intersects
and inside
methods, use the insideness
definition described in the Shape
class comments.- Since:
- 1.0
- Author:
- Sami Shaio, Herb Jellinek
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Rectangle2D
private static final int
int
float[]
float[]
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addPoint
(float x, float y) (package private) void
calculateBounds
(float[] xpoints, float[] ypoints, int npoints) boolean
contains
(float x, float y) boolean
org.joml.Vector2f
float
getMomentOfInertia
(float m) getPathIterator
(AffineTransform at, double flatness) boolean
inside
(float x, float y) Deprecated.void
void
reset()
void
translate
(float deltaX, float deltaY) (package private) void
updateBounds
(float x, float y)
-
Field Details
-
npoints
public int npoints -
xpoints
public float[] xpoints -
ypoints
public float[] ypoints -
bounds
-
MIN_LENGTH
private static final int MIN_LENGTH- See Also:
-
-
Constructor Details
-
Polygon
public Polygon() -
Polygon
public Polygon(float[] xpoints, float[] ypoints, int npoints)
-
-
Method Details
-
reset
public void reset() -
invalidate
public void invalidate() -
translate
public void translate(float deltaX, float deltaY) -
calculateBounds
void calculateBounds(float[] xpoints, float[] ypoints, int npoints) -
updateBounds
void updateBounds(float x, float y) -
addPoint
public void addPoint(float x, float y) -
getBoundingBox
-
inside
Deprecated. -
contains
public boolean contains(float x, float y) -
contains
-
getPathIterator
-
getPathIterator
-
getCenter
public org.joml.Vector2f getCenter() -
getMomentOfInertia
public float getMomentOfInertia(float m)
-