Class JavaPolygon2D
- java.lang.Object
-
- science.aist.imaging.api.domain.AbstractSurface<T,L>
-
- science.aist.imaging.api.domain.AbstractJavaPolygon<JavaPoint2D,JavaLine2D>
-
- science.aist.imaging.api.domain.twodimensional.JavaPolygon2D
-
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
JavaRectangleRotated2D
,JavaTriangle2D
public class JavaPolygon2D extends AbstractJavaPolygon<JavaPoint2D,JavaLine2D> implements Serializable
This class represents a Polygon using JavaPoint
- Since:
- 1.0
- Author:
- Christoph Praschl
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class science.aist.imaging.api.domain.AbstractJavaPolygon
points
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
JavaPolygon2D()
JavaPolygon2D(Collection<JavaPoint2D> points)
JavaPolygon2D(JavaPoint2D... points)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected double
calculateInnerDepth()
protected JavaPoint2D
calculateNormalvector()
protected JavaLine2D
createLine(JavaPoint2D p1, JavaPoint2D p2)
protected JavaPoint2D
createPoint(double x, double y, double z)
boolean
equals(Object o)
static JavaPolygon2D
getIntersection(JavaPolygon2D jp1, JavaPolygon2D jp2)
Method for getting the intersection polygon of two polygonsstatic JavaPolygon2D
getPolygonFromUnsortedPointCloud(JavaPoint2D... javaPoint2Ds)
Sorts the given point cloudint
hashCode()
boolean
isInConvexHull(JavaPoint2D point)
Method which checks if point is within the convex hullboolean
isInConvexHull(JavaPoint2D point, boolean considerPointsOnHull)
Method which checks if point is part of the convex hull if considerPointsOnHull flag is false only points within the hull are allowed else points can also be on the hull linesJavaPolygon2D
sort()
Sorts the points in the java polygon and returns a new sorted java polygon-
Methods inherited from class science.aist.imaging.api.domain.AbstractJavaPolygon
calculateContour, getPoints, getSize, isEmpty
-
Methods inherited from class science.aist.imaging.api.domain.AbstractSurface
getIntersection
-
-
-
-
Constructor Detail
-
JavaPolygon2D
protected JavaPolygon2D()
-
JavaPolygon2D
public JavaPolygon2D(JavaPoint2D... points)
-
JavaPolygon2D
public JavaPolygon2D(Collection<JavaPoint2D> points)
-
-
Method Detail
-
getPolygonFromUnsortedPointCloud
public static JavaPolygon2D getPolygonFromUnsortedPointCloud(JavaPoint2D... javaPoint2Ds)
Sorts the given point cloud- Parameters:
javaPoint2Ds
- the point cloud- Returns:
- the java polygon with the point cloud sorted.
-
getIntersection
public static JavaPolygon2D getIntersection(JavaPolygon2D jp1, JavaPolygon2D jp2)
Method for getting the intersection polygon of two polygons- Parameters:
jp1
- polygon 1 (must be sorted!)jp2
- polygon 2 (must be sorted!)- Returns:
- The intersection area as new JavaPolygon. Which is empty if given polygons are not sorted, are empty or there is no intersection area.
- See Also:
- Based on swtestacademy
-
createLine
protected JavaLine2D createLine(JavaPoint2D p1, JavaPoint2D p2)
- Specified by:
createLine
in classAbstractJavaPolygon<JavaPoint2D,JavaLine2D>
-
createPoint
protected JavaPoint2D createPoint(double x, double y, double z)
- Specified by:
createPoint
in classAbstractJavaPolygon<JavaPoint2D,JavaLine2D>
-
isInConvexHull
public boolean isInConvexHull(JavaPoint2D point)
Method which checks if point is within the convex hull- Parameters:
point
- Point which should be checked- Returns:
- True if point is in convex hull else False
-
isInConvexHull
public boolean isInConvexHull(JavaPoint2D point, boolean considerPointsOnHull)
Method which checks if point is part of the convex hull if considerPointsOnHull flag is false only points within the hull are allowed else points can also be on the hull lines- Parameters:
point
- Point which should be checkedconsiderPointsOnHull
- if the function should return true if the point is on the convex hull.- Returns:
- True if point is in convex hull else False
-
sort
public JavaPolygon2D sort()
Sorts the points in the java polygon and returns a new sorted java polygon- Returns:
- the java polygon with the point cloud sorted.
-
calculateInnerDepth
protected double calculateInnerDepth()
- Overrides:
calculateInnerDepth
in classAbstractJavaPolygon<JavaPoint2D,JavaLine2D>
-
calculateNormalvector
protected JavaPoint2D calculateNormalvector()
- Specified by:
calculateNormalvector
in classAbstractSurface<JavaPoint2D,JavaLine2D>
- Returns:
- the normalvector of this surface
-
-