APIdia Launch Partner
Top Fields Constructors Methods
com.badlogic.gdx.math

public final Class GeometryUtils

extends Object
Class Inheritance

Author
Nathan Sweet

Field Summary

Modifier and TypeField and Description
private static final Vector2
private static final Vector2
private static final Vector2

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static boolean
barycoordInsideTriangle(Vector2 barycentric)

Returns true if the barycentric coordinates are inside the triangle.

public static boolean
colinear(float x1, float y1, float x2, float y2, float x3, float y3)

public static void
ensureCCW(float[] polygon)

public static void
ensureCCW(float[] polygon, int offset, int count)

public static void
ensureClockwise(float[] polygon)

public static void
ensureClockwise(float[] polygon, int offset, int count)

public static Vector2

Returns:

interpolatedOut
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.

public static float

Returns:

interpolatedOut
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.

public static boolean
isCCW(float[] polygon, int offset, int count)

public static boolean
isClockwise(float[] polygon, int offset, int count)

public static float

Returns:

the lowest positive root or Float.Nan
lowestPositiveRoot
(float
the first coefficient of the quadric equation
a
,
float
the second coefficient of the quadric equation
b
,
float
the third coefficient of the quadric equation
c
)

Returns the lowest positive root of the quadric equation given by a * x * x + b * x + c = 0.

public static float
polygonArea(float[] polygon, int offset, int count)

Computes the area for a non-self-intersecting polygon.

public static Vector2
polygonCentroid(float[] polygon, int offset, int count, Vector2 centroid)

Returns the centroid for the specified non-self-intersecting polygon.

public static Vector2
quadrilateralCentroid(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, Vector2 centroid)

public static void
reverseVertices(float[] polygon, int offset, int count)

public static Vector2

Returns:

barycentricOut
toBarycoord
(Vector2 p, Vector2 a, Vector2 b, Vector2 c, Vector2 barycentricOut)

Computes the barycentric coordinates v,w for the specified point in the triangle.

public static float
triangleArea(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)

Returns the circumcenter of the triangle.

public static float
triangleCircumradius(float x1, float y1, float x2, float y2, float x3, float y3)

Returns the circumradius of the triangle.

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.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

tmp1back to summary
private static final Vector2 tmp1
tmp2back to summary
private static final Vector2 tmp2
tmp3back to summary
private static final Vector2 tmp3

Constructor Detail

GeometryUtilsback to summary
private GeometryUtils()

Method Detail

barycoordInsideTriangleback to summary
public static boolean barycoordInsideTriangle(Vector2 barycentric)

Returns true if the barycentric coordinates are inside the triangle.

colinearback to summary
public static boolean colinear(float x1, float y1, float x2, float y2, float x3, float y3)
ensureCCWback to summary
public static void ensureCCW(float[] polygon)
ensureCCWback to summary
public static void ensureCCW(float[] polygon, int offset, int count)
ensureClockwiseback to summary
public static void ensureClockwise(float[] polygon)
ensureClockwiseback to summary
public static void ensureClockwise(float[] polygon, int offset, int count)
fromBarycoordback to summary
public 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.

Returns:Vector2

interpolatedOut

fromBarycoordback to summary
public 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.

Returns:float

interpolatedOut

isCCWback to summary
public static boolean isCCW(float[] polygon, int offset, int count)
isClockwiseback to summary
public static boolean isClockwise(float[] polygon, int offset, int count)
lowestPositiveRootback to summary
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:float

the first coefficient of the quadric equation

b:float

the second coefficient of the quadric equation

c:float

the third coefficient of the quadric equation

Returns:float

the lowest positive root or Float.Nan

polygonAreaback to summary
public static float polygonArea(float[] polygon, int offset, int count)

Computes the area for a non-self-intersecting polygon.

polygonCentroidback to summary
public static Vector2 polygonCentroid(float[] polygon, int offset, int count, Vector2 centroid)

Returns the centroid for the specified non-self-intersecting polygon. The input points must not be colinear.

quadrilateralCentroidback to summary
public static Vector2 quadrilateralCentroid(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, Vector2 centroid)
reverseVerticesback to summary
public static void reverseVertices(float[] polygon, int offset, int count)
toBarycoordback to summary
public 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. The input points must not be colinear.

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.toBarycoord(p, a, b, c, barycentric);
// THEN:
float u = 1f - 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;
// OR:
GeometryUtils.fromBarycoord(barycentric, aa, bb, cc, out);
Returns:Vector2

barycentricOut

triangleAreaback to summary
public static float triangleArea(float x1, float y1, float x2, float y2, float x3, float y3)
triangleCentroidback to summary
public static Vector2 triangleCentroid(float x1, float y1, float x2, float y2, float x3, float y3, Vector2 centroid)
triangleCircumcenterback to summary
public static Vector2 triangleCircumcenter(float x1, float y1, float x2, float y2, float x3, float y3, Vector2 circumcenter)

Returns the circumcenter of the triangle. The input points must not be colinear.

triangleCircumradiusback to summary
public static float triangleCircumradius(float x1, float y1, float x2, float y2, float x3, float y3)

Returns the circumradius of the triangle. The input points must not be colinear.

triangleQualityback to summary
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.