Package geometries
Class Polygon
java.lang.Object
geometries.Geometry
geometries.Polygon
- All Implemented Interfaces:
Intersectible
- Direct Known Subclasses:
Triangle
public class Polygon extends Geometry
This class represents a polygon in three dimensional space. A polygon is a plane figure that is described by a finite
number of straight line segments connected to form a polygonal circuit.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and Type Method Description geometries.Boundary
boundary()
Get theBoundary
of this intersectible.java.util.List<Intersection>
intersect(LineSegment line)
Calculates all the intersections between a givenLineSegment
and this object.NormalizedVector
normal(Point p)
Calculates the normal to thePolygon
.Methods inherited from class geometries.Geometry
intersection
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
Polygon
This constructor accepts a list of the vertices of the polygon.- Parameters:
material
- TheMaterial
the polygon is made from.vertices
- A list of the vertices of the polygon, in order.- Throws:
java.lang.IllegalArgumentException
- if there are less than three significant vertices, any of the vertices are not on the same plane as the rest, the vertices are out of order and thus form a non-convex polygon, consecutive vertices are repeated, or the last point is equal to the first point.
-
-
Method Details
-
normal
-
intersect
Description copied from interface:Intersectible
Calculates all the intersections between a givenLineSegment
and this object.- Parameters:
line
- TheLineSegment
to check for intersections.- Returns:
- A list of all the intersections with the given
LineSegment
.
-
boundary
public geometries.Boundary boundary()Description copied from interface:Intersectible
Get theBoundary
of this intersectible.- Returns:
- The bounding box of this intersectible.
-