public final class GeometryUtils extends Object
Constructor and Description |
---|
GeometryUtils() |
Modifier and Type | Method and Description |
---|---|
static boolean |
barycoordInsideTriangle(Vector2 barycentric)
Returns true if the barycentric coordinates are inside the triangle.
|
static boolean |
colinear(float x1,
float y1,
float x2,
float y2,
float x3,
float y3) |
static void |
ensureCCW(float[] polygon) |
static float |
fromBarycoord(Vector2 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 Vector2 |
fromBarycoord(Vector2 barycentric,
Vector2 a,
Vector2 b,
Vector2 c,
Vector2 interpolatedOut)
Returns interpolated values given the barycentric coordinates of a point in a triangle and the values at each vertex.
|
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 float |
polygonArea(float[] polygon,
int offset,
int count)
Computes the area for a convex polygon.
|
static Vector2 |
polygonCentroid(float[] polygon,
int offset,
int count,
Vector2 centroid)
Returns the centroid for the specified non-self-intersecting polygon.
|
static Vector2 |
quadrilateralCentroid(float x1,
float y1,
float x2,
float y2,
float x3,
float y3,
float x4,
float y4,
Vector2 centroid) |
static Vector2 |
toBarycoord(Vector2 p,
Vector2 a,
Vector2 b,
Vector2 c,
Vector2 barycentricOut)
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 Vector2 |
triangleCentroid(float x1,
float y1,
float x2,
float y2,
float x3,
float y3,
Vector2 centroid) |
static Vector2 |
triangleCircumcenter(float x1,
float y1,
float x2,
float y2,
float x3,
float y3,
Vector2 circumcenter)
Returns the circumcenter of the triangle.
|
public static Vector2 toBarycoord(Vector2 p, Vector2 a, Vector2 b, Vector2 c, Vector2 barycentricOut)
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:
GeometryUtils.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;
public static boolean barycoordInsideTriangle(Vector2 barycentric)
public static Vector2 fromBarycoord(Vector2 barycentric, Vector2 a, Vector2 b, Vector2 c, Vector2 interpolatedOut)
public static float fromBarycoord(Vector2 barycentric, float a, float b, float c)
public static float lowestPositiveRoot(float a, float b, float c)
a
- the first coefficient of the quadric equationb
- the second coefficient of the quadric equationc
- the third coefficient of the quadric equationpublic static boolean colinear(float x1, float y1, float x2, float y2, float x3, float y3)
public static Vector2 triangleCentroid(float x1, float y1, float x2, float y2, float x3, float y3, Vector2 centroid)
public static Vector2 triangleCircumcenter(float x1, float y1, float x2, float y2, float x3, float y3, Vector2 circumcenter)
public static float triangleArea(float x1, float y1, float x2, float y2, float x3, float y3)
public static Vector2 quadrilateralCentroid(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, Vector2 centroid)
public static Vector2 polygonCentroid(float[] polygon, int offset, int count, Vector2 centroid)
public static float polygonArea(float[] polygon, int offset, int count)
public static void ensureCCW(float[] polygon)
Copyright © 2015. All rights reserved.