Package arc.math.geom
Class Geometry
java.lang.Object
arc.math.geom.Geometry
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic interface -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Point2[]Points representing cardinal directions, starting at the left and going counter-clockwise.static final Point2[]Points representing cardinal directions, starting at the left and going counter-clockwise.static final int[]static final int[]static final Point2[]static final Point2[] -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanbarycoordInsideTriangle(Vec2 barycentric) Returns true if the barycentric coordinates are inside the triangle.static voidstatic voidstatic booleancolinear(float x1, float y1, float x2, float y2, float x3, float y3) static Point2d4(int i) static intd4x(int i) static intd4y(int i) static Point2d8(int i) static Point2d8edge(int i) static voidensureCCW(float[] polygon) static voidensureCCW(float[] polygon, int offset, int count) static <T extends Position>
TfindClosest(float x, float y, Iterable<T> list) static <T extends Position>
TfindClosest(float x, float y, T[] list) static <T extends Position>
TfindFurthest(float x, float y, Iterable<T> list) static floatfromBarycoord(Vec2 barycentric, float a, float b, float c) Returns an interpolated value given the barycentric coordinates of a point in a triangle and the values at each vertex.static Vec2Returns interpolated values given the barycentric coordinates of a point in a triangle and the values at each vertex.static Point2[]static Point2[]static Point2[]static booleanisClockwise(float[] polygon, int offset, int count) static floatiterateLine(float start, float x1, float y1, float x2, float y2, float segment, Floatc2 pos) static voiditeratePolygon(Floatc2 path, float[] vertices) static voiditeratePolySegments(float[] vertices, Floatc4 it) static floatlowestPositiveRoot(float a, float b, float c) Returns the lowest positive root of the quadric equation given by a* x * x + b * x + c = 0.static Vec2Checks for collisions between two rectangles, and returns the correct delta vector of A.static Vec2[]pixelCircle(float tindex) static Vec2[]pixelCircle(float index, Geometry.SolidChecker checker) static floatpolygonArea(float[] polygon, int offset, int count) Computes the area for a convex polygon.static Vec2polygonCentroid(float[] polygon, int offset, int count, Vec2 centroid) Returns the centroid for the specified non-self-intersecting polygon.static Vec2quadrilateralCentroid(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, Vec2 centroid) static booleanraycast(int x0f, int y0f, int x1, int y1, Geometry.Raycaster cons) static Vec2raycastRect(float startx, float starty, float endx, float endy, float x, float y, float halfx, float halfy) static Vec2raycastRect(float startx, float starty, float endx, float endy, Rect rect) static float[]regPoly(int amount, float size) returns a regular polygon with {amount} sidesstatic Vec2Computes the barycentric coordinates v,w for the specified point in the triangle.static floattriangleArea(float x1, float y1, float x2, float y2, float x3, float y3) static Vec2triangleCentroid(float x1, float y1, float x2, float y2, float x3, float y3, Vec2 centroid) static Vec2triangleCircumcenter(float x1, float y1, float x2, float y2, float x3, float y3, Vec2 circumcenter) Returns the circumcenter of the triangle.static floattriangleCircumradius(float x1, float y1, float x2, float y2, float x3, float y3) static floattriangleQuality(float x1, float y1, float x2, float y2, float x3, float y3) Ratio of circumradius to shortest edge as a measure of triangle quality.static FloatSeqvectorsToFloats(Seq<Vec2> result)
-
Field Details
-
d4
Points representing cardinal directions, starting at the left and going counter-clockwise. -
d4c
Points representing cardinal directions, starting at the left and going counter-clockwise. Also contains a center point: 0,0. -
d4x
public static final int[] d4x -
d4y
public static final int[] d4y -
d8
-
d8edge
-
-
Constructor Details
-
Geometry
public Geometry()
-
-
Method Details
-
d4
-
d4x
public static int d4x(int i) -
d4y
public static int d4y(int i) -
d8
-
d8edge
-
circle
-
circle
-
vectorsToFloats
-
findClosest
-
findClosest
-
findFurthest
-
pixelCircle
-
pixelCircle
-
regPoly
public static float[] regPoly(int amount, float size) returns a regular polygon with {amount} sides -
iterateLine
public static float iterateLine(float start, float x1, float y1, float x2, float y2, float segment, Floatc2 pos) -
iteratePolySegments
-
iteratePolygon
-
getD4Points
-
getD8Points
-
getD8EdgePoints
-
raycast
-
raycastRect
-
raycastRect
public static Vec2 raycastRect(float startx, float starty, float endx, float endy, float x, float y, float halfx, float halfy) -
overlap
Checks for collisions between two rectangles, and returns the correct delta vector of A. Note: The same vector instance is returned each time! -
toBarycoord
Computes the barycentric coordinates v,w for the specified point in the triangle.If barycentric.x >= 0 && barycentric.y >= 0 && barycentric.x + barycentric.y <= 1 then the point is inside the triangle.
If vertices a,b,c have values aa,bb,cc then to get an interpolated value at point p:
Geometry.barycentric(p, a, b, c, barycentric); float u = 1.f - barycentric.x - barycentric.y; float x = u * aa.x + barycentric.x * bb.x + barycentric.y * cc.x; float y = u * aa.y + barycentric.x * bb.y + barycentric.y * cc.y;
- Returns:
- barycentricOut
-
barycoordInsideTriangle
Returns true if the barycentric coordinates are inside the triangle. -
fromBarycoord
Returns interpolated values given the barycentric coordinates of a point in a triangle and the values at each vertex.- Returns:
- interpolatedOut
-
fromBarycoord
Returns an interpolated value given the barycentric coordinates of a point in a triangle and the values at each vertex.- Returns:
- interpolatedOut
-
lowestPositiveRoot
public static float lowestPositiveRoot(float a, float b, float c) Returns the lowest positive root of the quadric equation given by a* x * x + b * x + c = 0. If no solution is given Float.Nan is returned.- Parameters:
a- the first coefficient of the quadric equationb- the second coefficient of the quadric equationc- the third coefficient of the quadric equation- Returns:
- the lowest positive root or Float.Nan
-
colinear
public static boolean colinear(float x1, float y1, float x2, float y2, float x3, float y3) -
triangleCentroid
-
triangleCircumcenter
public static Vec2 triangleCircumcenter(float x1, float y1, float x2, float y2, float x3, float y3, Vec2 circumcenter) Returns the circumcenter of the triangle. The input points must not be colinear. -
triangleCircumradius
public static float triangleCircumradius(float x1, float y1, float x2, float y2, float x3, float y3) -
triangleQuality
public static float triangleQuality(float x1, float y1, float x2, float y2, float x3, float y3) Ratio of circumradius to shortest edge as a measure of triangle quality.Gary L. Miller, Dafna Talmor, Shang-Hua Teng, and Noel Walkington. A Delaunay Based Numerical Method for Three Dimensions: Generation, Formulation, and Partition.
-
triangleArea
public static float triangleArea(float x1, float y1, float x2, float y2, float x3, float y3) -
quadrilateralCentroid
-
polygonCentroid
Returns the centroid for the specified non-self-intersecting polygon. -
polygonArea
public static float polygonArea(float[] polygon, int offset, int count) Computes the area for a convex polygon. -
ensureCCW
public static void ensureCCW(float[] polygon) -
ensureCCW
public static void ensureCCW(float[] polygon, int offset, int count) -
isClockwise
public static boolean isClockwise(float[] polygon, int offset, int count)
-