public class BasicPolygons extends Object
Constructor and Description |
---|
BasicPolygons()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
areAllPointOutside(List<? extends Tuple2d> polygon,
List<? extends Tuple2d> testP)
Test if all points from Ptest are outside of P.
|
boolean |
areAllPointsInside(List<? extends Tuple2d> polygon,
List<? extends Tuple2d> testP)
Test if all points Ptest are inside polygon P.
|
double |
getPolyArea(List<? extends Tuple2d> p)
Calculates area of polygon.
|
double |
getPolyPerim(List<? extends Tuple2d> p)
Calculates perimeter of polygon.
|
boolean |
isPointInside(List<? extends Tuple2d> p,
Tuple2d testP)
Test whether Ptest is inside polygon P
|
Point2d |
polygonCenterOfMass(List<? extends Tuple2d> polygon)
Get center of mass of polygon.
|
public double getPolyArea(List<? extends Tuple2d> p)
Supports triangles, regular and irregular polygons, convex or concave polygons
Warning
Polygon can not intersect itself.
p
- Vertices of polygon in specified orderpublic double getPolyPerim(List<? extends Tuple2d> p)
p
- Vertices of polygon in specified orderpublic boolean isPointInside(List<? extends Tuple2d> p, Tuple2d testP)
p
- Vertices of polygon in specified ordertestP
- Point to be testedpublic boolean areAllPointsInside(List<? extends Tuple2d> polygon, List<? extends Tuple2d> testP)
polygon
- polygon to test points withtestP
- points to testisPointInside(List, Tuple2d)
public boolean areAllPointOutside(List<? extends Tuple2d> polygon, List<? extends Tuple2d> testP)
polygon
- polygon to test points withtestP
- points to testisPointInside(List, Tuple2d)
public Point2d polygonCenterOfMass(List<? extends Tuple2d> polygon)
Warning
Require correct polygon with non crossing edges.
polygon
- Vertices of polygon in specified orderIllegalArgumentException
- when defective polygon is given (area equals 0)Copyright © 2002–2019 Department of Computer Science, Warwick University. All rights reserved.