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.Boundaryboundary()Get theBoundaryof this intersectible.java.util.List<Intersection>intersect(LineSegment line)Calculates all the intersections between a givenLineSegmentand this object.NormalizedVectornormal(Point p)Calculates the normal to thePolygon.Methods inherited from class geometries.Geometry
intersectionMethods 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- TheMaterialthe 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:IntersectibleCalculates all the intersections between a givenLineSegmentand this object.- Parameters:
line- TheLineSegmentto check for intersections.- Returns:
- A list of all the intersections with the given
LineSegment.
-
boundary
public geometries.Boundary boundary()Description copied from interface:IntersectibleGet theBoundaryof this intersectible.- Returns:
- The bounding box of this intersectible.
-