Package arc.math.geom
Class Geometry
java.lang.Object
arc.math.geom.Geometry
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
static interface
-
Field Summary
Modifier 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
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
barycoordInsideTriangle
(Vec2 barycentric) Returns true if the barycentric coordinates are inside the triangle.static void
static void
static boolean
colinear
(float x1, float y1, float x2, float y2, float x3, float y3) static Point2
d4
(int i) static int
d4x
(int i) static int
d4y
(int i) static Point2
d8
(int i) static Point2
d8edge
(int i) static void
ensureCCW
(float[] polygon) static void
ensureCCW
(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 float
fromBarycoord
(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 Vec2
Returns 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 boolean
isClockwise
(float[] polygon, int offset, int count) static float
iterateLine
(float start, float x1, float y1, float x2, float y2, float segment, Floatc2 pos) static void
iteratePolygon
(Floatc2 path, float[] vertices) static void
iteratePolySegments
(float[] vertices, Floatc4 it) 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.static Vec2
Checks 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 float
polygonArea
(float[] polygon, int offset, int count) Computes the area for a convex polygon.static Vec2
polygonCentroid
(float[] polygon, int offset, int count, Vec2 centroid) Returns the centroid for the specified non-self-intersecting polygon.static Vec2
quadrilateralCentroid
(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, Vec2 centroid) static boolean
raycast
(int x0f, int y0f, int x1, int y1, Geometry.Raycaster cons) static Vec2
raycastRect
(float startx, float starty, float endx, float endy, float x, float y, float halfx, float halfy) static Vec2
raycastRect
(float startx, float starty, float endx, float endy, Rect rect) static float[]
regPoly
(int amount, float size) returns a regular polygon with {amount} sidesstatic Vec2
Computes the barycentric coordinates v,w for the specified point in the triangle.static float
triangleArea
(float x1, float y1, float x2, float y2, float x3, float y3) static Vec2
triangleCentroid
(float x1, float y1, float x2, float y2, float x3, float y3, Vec2 centroid) static Vec2
triangleCircumcenter
(float x1, float y1, float x2, float y2, float x3, float y3, Vec2 circumcenter) Returns the circumcenter of the triangle.static float
triangleCircumradius
(float x1, float y1, float x2, float y2, float x3, float y3) 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.static FloatSeq
vectorsToFloats
(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)
-