28package com.jogamp.math;
32import com.jogamp.graph.geom.Vertex;
33import com.jogamp.math.geom.plane.Winding;
40 return 0f == vec.x() && 0f == vec.y();
49 public static boolean isZero(
final float x,
final float y,
final float z,
final float epsilon) {
61 public static boolean isZero(
final float x,
final float y,
final float z) {
75 final float dx = v1[0] - v2[0];
76 final float dy = v1[1] - v2[1];
77 final float dz = v1[2] - v2[2];
78 return dx * dx + dy * dy + dz * dz;
84 public static float distVec3(
final float[] v1,
final float[] v2) {
92 return vec[0]*vec[0] + vec[1]*vec[1];
99 return vec[0]*vec[0] + vec[1]*vec[1] + vec[2]*vec[2];
106 float v = vec[0+offset];
146 public static float[]
normalizeVec3(
final float[] vector,
final int offset) {
149 vector[0+offset] = 0f;
150 vector[1+offset] = 0f;
151 vector[2+offset] = 0f;
154 vector[0+offset] *= invSqr;
155 vector[1+offset] *= invSqr;
156 vector[2+offset] *= invSqr;
168 public static float[]
scaleVec2(
final float[] result,
final float[] vector,
final float scale) {
169 result[0] = vector[0] * scale;
170 result[1] = vector[1] * scale;
181 public static float[]
scaleVec2(
final float[] result,
final float[] vector,
final float[] scale)
183 result[0] = vector[0] * scale[0];
184 result[1] = vector[1] * scale[1];
195 public static float[]
divVec2(
final float[] result,
final float[] vector,
final float scale) {
196 result[0] = vector[0] / scale;
197 result[1] = vector[1] / scale;
208 public static float[]
divVec2(
final float[] result,
final float[] vector,
final float[] scale)
210 result[0] = vector[0] / scale[0];
211 result[1] = vector[1] / scale[1];
222 public static float[]
addVec2(
final float[] result,
final float[] v1,
final float[] v2) {
223 result[0] = v1[0] + v2[0];
224 result[1] = v1[1] + v2[1];
235 public static float[]
subVec2(
final float[] result,
final float[] v1,
final float[] v2) {
236 result[0] = v1[0] - v2[0];
237 result[1] = v1[1] - v2[1];
247 public static float[]
crossVec3(
final float[] r,
final int r_offset,
final float[] v1,
final int v1_offset,
final float[] v2,
final int v2_offset)
249 r[0+r_offset] = v1[1+v1_offset] * v2[2+v2_offset] - v1[2+v1_offset] * v2[1+v2_offset];
250 r[1+r_offset] = v1[2+v1_offset] * v2[0+v2_offset] - v1[0+v1_offset] * v2[2+v2_offset];
251 r[2+r_offset] = v1[0+v1_offset] * v2[1+v2_offset] - v1[1+v1_offset] * v2[0+v2_offset];
262 result.
set( (p1.x() + p2.x())*0.5f,
263 (p1.y() + p2.y())*0.5f,
264 (p1.z() + p2.z())*0.5f );
276 return a.x()*b.y()*c.z() + a.y()*b.z()*c.x() + a.z()*b.x()*c.y() - a.x()*b.z()*c.y() - a.y()*b.x()*c.z() - a.z()*b.y()*c.x();
308 return sqlend(a.
x(), a.
y()) *
triArea(b, c, d) -
309 sqlend(b.
x(), b.
y()) *
triArea(a, c, d) +
310 sqlend(c.
x(), c.
y()) *
triArea(a, b, d) -
313 private static double sqlend(
final double x,
final double y) {
332 private static double triArea(
final double ax,
final double ay,
final double bx,
final double by,
final double cx,
final double cy){
333 return (bx - ax) * (cy - ay) - (by - ay) * (cx - ax);
356 final float dotAC_AC = ac.
dot(ac);
357 final float dotAC_AB = ac.
dot(ab);
358 final float dotAB_AB = ab.
dot(ab);
359 final float dotAC_AP = ac.
dot(ap);
360 final float dotAB_AP = ab.
dot(ap);
363 final float invDenom = 1 / (dotAC_AC * dotAB_AB - dotAC_AB * dotAC_AB);
364 final float u = (dotAB_AB * dotAC_AP - dotAC_AB * dotAB_AP) * invDenom;
365 final float v = (dotAC_AC * dotAB_AP - dotAC_AB * dotAC_AP) * invDenom;
368 return (u >= 0) && (v >= 0) && (u + v < 1);
392 final float dotAC_AC = ac.
dot(ac);
393 final float dotAC_AB = ac.
dot(ab);
394 final float dotAB_AB = ab.
dot(ab);
397 final float invDenom = 1 / (dotAC_AC * dotAB_AB - dotAC_AB * dotAC_AB);
400 final float dotAC_AP1 = ac.
dot(ap);
401 final float dotAB_AP1 = ab.
dot(ap);
402 final float u = (dotAB_AB * dotAC_AP1 - dotAC_AB * dotAB_AP1) * invDenom;
403 final float v = (dotAC_AC * dotAB_AP1 - dotAC_AB * dotAC_AP1) * invDenom;
406 if ( (u >= 0) && (v >= 0) && (u + v < 1) ) {
413 final float dotAC_AP2 = ac.
dot(ap);
414 final float dotAB_AP2 = ab.
dot(ap);
415 final float u = (dotAB_AB * dotAC_AP2 - dotAC_AB * dotAB_AP2) * invDenom;
416 final float v = (dotAC_AC * dotAB_AP2 - dotAC_AB * dotAC_AP2) * invDenom;
419 if ( (u >= 0) && (v >= 0) && (u + v < 1) ) {
426 final float dotAC_AP3 = ac.
dot(ap);
427 final float dotAB_AP3 = ab.
dot(ap);
428 final float u = (dotAB_AB * dotAC_AP3 - dotAC_AB * dotAB_AP3) * invDenom;
429 final float v = (dotAC_AC * dotAB_AP3 - dotAC_AB * dotAC_AP3) * invDenom;
432 if ( (u >= 0) && (v >= 0) && (u + v < 1) ) {
455 final float epsilon) {
461 final float dotAC_AC = ac.
dot(ac);
462 final float dotAC_AB = ac.
dot(ab);
463 final float dotAB_AB = ab.
dot(ab);
466 final float invDenom = 1 / (dotAC_AC * dotAB_AB - dotAC_AB * dotAC_AB);
469 final float dotAC_AP1 = ac.
dot(ap);
470 final float dotAB_AP1 = ab.
dot(ap);
471 final float u = (dotAB_AB * dotAC_AP1 - dotAC_AB * dotAB_AP1) * invDenom;
472 final float v = (dotAC_AC * dotAB_AP1 - dotAC_AB * dotAC_AP1) * invDenom;
484 final float dotAC_AP2 = ac.
dot(ap);
485 final float dotAB_AP2 = ab.
dot(ap);
486 final float u = (dotAB_AB * dotAC_AP2 - dotAC_AB * dotAB_AP2) * invDenom;
487 final float v = (dotAC_AC * dotAB_AP2 - dotAC_AB * dotAC_AP2) * invDenom;
499 final float dotAC_AP3 = ac.
dot(ap);
500 final float dotAB_AP3 = ab.
dot(ap);
501 final float u = (dotAB_AB * dotAC_AP3 - dotAC_AB * dotAB_AP3) * invDenom;
502 final float v = (dotAC_AC * dotAB_AP3 - dotAC_AB * dotAC_AP3) * invDenom;
543 return triArea(a,b,c) > DoubleUtil.EPSILON ? Winding.CCW : Winding.CW ;
558 public static double area(
final List<? extends Vert2fImmutable> vertices) {
559 final int n = vertices.size();
561 for (
int p = n - 1, q = 0; q < n; p = q++) {
564 area += (double)pCoord.
x() * (double)qCoord.
y() - (double)qCoord.
x() * (double)pCoord.
y();
583 return area(vertices) >= 0 ? Winding.CCW : Winding.CW ;
601 resultV4.
set(normalVec3, -normalVec3.
dot(pVec3));
625 resultVec4.
set(temp3V3, -temp3V3.
dot(v1));
643 final float tmp = ray.
dir.
dot(plane3);
671 final float alpha = (a.
x()*b.
y()-a.
y()*b.
x());
672 final float beta = (c.
x()*d.
y()-c.
y()*d.
y());
676 return result.
set(xi, yi, 0);
693 final float alpha = (a.
x()*b.
y()-a.
y()*b.
x());
694 final float beta = (c.
x()*d.
y()-c.
y()*d.
y());
698 final float gamma = (xi - a.
x())/(b.
x() - a.
x());
699 final float gamma1 = (xi - c.
x())/(d.
x() - c.
x());
700 if(gamma <= 0 || gamma >= 1)
return null;
701 if(gamma1 <= 0 || gamma1 >= 1)
return null;
703 return result.
set(xi, yi, 0);
724 final float alpha = (a.
x()*b.
y()-a.
y()*b.
x());
725 final float beta = (c.
x()*d.
y()-c.
y()*d.
y());
728 final float gamma0 = (xi - a.
x())/(b.
x() - a.
x());
729 final float gamma1 = (xi - c.
x())/(d.
x() - c.
x());
730 if(gamma0 <= 0 || gamma0 >= 1 || gamma1 <= 0 || gamma1 >= 1) {
775 final float rxs = r.
cross(s);
780 final float qpxr = q_p.
cross(r);
785 final float qp_dot_r = q_p.
dot(r);
786 final float pq_dot_s = p_q.
dot(s);
789 if ( ( epsilon <= qp_dot_r && qp_dot_r - r.
dot(r) <= epsilon ) ||
790 ( epsilon <= pq_dot_s && pq_dot_s - s.
dot(s) <= epsilon ) )
810 final float qpxr = q_p.
cross(r);
816 final float t = q_p.
cross(s) / rxs;
819 final float u = qpxr / rxs;
822 if ( (epsilon <= t && t - 1 <= epsilon) && (epsilon <= u && u - 1 <= epsilon) )
853 final float rxs = r.
cross(s);
858 final float qpxr = q_p.
cross(r);
863 final float qp_dot_r = q_p.
dot(r);
864 final float pq_dot_s = p_q.
dot(s);
867 if ( ( epsilon <= qp_dot_r && qp_dot_r - r.
dot(r) <= epsilon ) ||
868 ( epsilon <= pq_dot_s && pq_dot_s - s.
dot(s) <= epsilon ) )
886 final float qpxr = q_p.
cross(r);
892 final float t = q_p.
cross(s) / rxs;
895 final float u = qpxr / rxs;
898 if ( (epsilon <= t && t - 1 <= epsilon) && (epsilon <= u && u - 1 <= epsilon) )
924 final float epsilon,
final boolean doCollinear)
927 final float rx = p2.
x() - p.
x();
928 final float ry = p2.
y() - p.
y();
929 final float sx = q2.
x() - q.
x();
930 final float sy = q2.
y() - q.
y();
931 final float rxs = rx * sy - ry * sx;
935 final float q_px = q.
x() - p.
x();
936 final float q_py = q.
y() - p.
y();
937 final float qpxr = q_px * ry - q_py * rx;
941 final float p_qx = p.
x() - q.
x();
942 final float p_qy = p.
y() - q.
y();
943 final float qp_dot_r = q_px * rx + q_py * ry;
944 final float pq_dot_s = p_qx * sx + p_qy * sy;
945 final float r_dot_r = rx * rx + ry * ry;
946 final float s_dot_s = sx * sx + sy * sy;
949 if ( ( epsilon <= qp_dot_r && qp_dot_r - r_dot_r <= epsilon ) ||
950 ( epsilon <= pq_dot_s && pq_dot_s - s_dot_s <= epsilon ) )
967 final float q_px = q.
x() - p.
x();
968 final float q_py = q.
y() - p.
y();
969 final float qpxr = q_px * ry - q_py * rx;
975 final float t = ( q_px * sy - q_py * sx ) / rxs;
978 final float u = qpxr / rxs;
981 if ( (epsilon <= t && t - 1 <= epsilon) && (epsilon <= u && u - 1 <= epsilon) )
1029 final float rx = p2.
x() - p.
x();
1030 final float ry = p2.
y() - p.
y();
1031 final float sx = q2.
x() - q.
x();
1032 final float sy = q2.
y() - q.
y();
1033 final float rxs = rx * sy - ry * sx;
1042 final float q_px = q.
x() - p.
x();
1043 final float q_py = q.
y() - p.
y();
1044 final float qpxr = q_px * ry - q_py * rx;
1050 final float t = ( q_px * sy - q_py * sx ) / rxs;
1053 final float u = qpxr / rxs;
1056 if ( (epsilon <= t && t - 1 <= epsilon) && (epsilon <= u && u - 1 <= epsilon) )
1092 public static boolean isConvex0(
final List<? extends Vert2fImmutable> polyline,
final boolean shortIsConvex) {
1093 final int polysz = polyline.size();
1095 return shortIsConvex;
1112 for(
int i=0; i<polysz; ++i) {
1115 next = polyline.get(i);
1118 final float bx = curr.
x() - prev.
x();
1119 final float by = curr.
y() - prev.
y();
1122 final float ax = next.
x() - curr.
x();
1123 final float ay = next.
y() - curr.
y();
1130 }
else if( xSign < 0 ) {
1131 xFlips = xFlips + 1;
1134 }
else if( ax < -eps ) {
1137 }
else if ( xSign > 0 ) {
1138 xFlips = xFlips + 1;
1149 }
else if( ySign < 0 ) {
1150 yFlips = yFlips + 1;
1153 }
else if( ay < -eps ) {
1156 }
else if( ySign > 0 ) {
1157 yFlips = yFlips + 1;
1167 final float w = bx*ay - ax*by;
1170 }
else if( wSign > eps && w < -eps ) {
1172 }
else if( wSign < -eps && w > eps ) {
1178 if( xSign != 0 && xFirstSign != 0 && xSign != xFirstSign ) {
1179 xFlips = xFlips + 1;
1181 if( ySign != 0 && yFirstSign != 0 && ySign != yFirstSign ) {
1182 yFlips = yFlips + 1;
1186 if( xFlips != 2 || yFlips != 2 ) {
1195 private static int cmod(
final int i,
final int count) {
1213 public static boolean isConvex1(
final List<Vertex> polyline,
final boolean shortIsConvex) {
1214 final int polysz = polyline.size();
1216 return shortIsConvex;
1235 v0 = polyline.get(cmod(offset, polysz));
1236 }
while( !v0.
isOnCurve() && offset < polysz );
1237 if( offset >= polysz ) {
1238 return shortIsConvex;
1242 v1 = polyline.get(cmod(offset, polysz));
1243 }
while( !v1.
isOnCurve() && offset < polysz );
1244 if( offset >= polysz ) {
1245 return shortIsConvex;
1249 while( offset < polysz ) {
1254 v1 = polyline.get(cmod(offset, polysz));
1255 }
while( !v1.
isOnCurve() && offset < polysz );
1256 if( offset >= polysz ) {
1261 final float bx = v0.
x() - vp.
x();
1262 final float by = v0.
y() - vp.
y();
1265 final float ax = v1.
x() - v0.
x();
1266 final float ay = v1.
y() - v0.
y();
1273 }
else if( xSign < 0 ) {
1274 xFlips = xFlips + 1;
1277 }
else if( ax < -eps ) {
1280 }
else if ( xSign > 0 ) {
1281 xFlips = xFlips + 1;
1292 }
else if( ySign < 0 ) {
1293 yFlips = yFlips + 1;
1296 }
else if( ay < -eps ) {
1299 }
else if( ySign > 0 ) {
1300 yFlips = yFlips + 1;
1310 final float w = bx*ay - ax*by;
1313 }
else if( wSign > eps && w < -eps ) {
1315 }
else if( wSign < -eps && w > eps ) {
1321 if( xSign != 0 && xFirstSign != 0 && xSign != xFirstSign ) {
1322 xFlips = xFlips + 1;
1324 if( ySign != 0 && yFirstSign != 0 && ySign != yFirstSign ) {
1325 yFlips = yFlips + 1;
1329 if( xFlips != 2 || yFlips != 2 ) {
1341 final int polysz = polyline.size();
1345 for (
int i = 0; i < polysz-1; i++) {
1346 final Vertex p0 = polyline.get(i);
1347 final Vertex p1 = polyline.get(i+1);
1348 for (
int j = i+2; j < polysz; j++) {
1349 if( i != 0 || j != (polysz-1) ) {
1350 final Vertex q0 = polyline.get(j);
1351 final Vertex q1 = polyline.get((j+1)%polysz);
A Vertex exposing Vec3f vertex- and texture-coordinates.
final boolean isOnCurve()
Basic Double math utility functions.
static final double EPSILON
Epsilon for floating point {@value}, as once computed via getMachineEpsilon() on an AMD-64 CPU.
Basic Float math utility functions.
static int compare(final float a, final float b)
Returns -1, 0 or 1 if a is less, equal or greater than b, disregarding epsilon but considering NaN,...
static final float EPSILON
Epsilon for floating point {@value}, as once computed via getMachineEpsilon() on an AMD-64 CPU.
static boolean isZero(final float a, final float epsilon)
Returns true if value is zero, i.e.
static float sqrt(final float a)
Simple compound denoting a ray.
final Vec3f dir
Normalized direction vector of ray.
final Vec3f orig
Origin of Ray.
2D Vector based upon two float components.
float cross(final Vec2f o)
Returns cross product of this vectors and the given one, i.e.
Vec2f plus(final Vec2f arg)
Returns this + arg; creates new vector.
Vec2f minus(final Vec2f arg)
Returns this - arg; creates new vector.
float dot(final Vec2f arg)
Return the dot product of this vector and the given one.
Vec2f mul(final float val)
Returns this * val; creates new vector.
3D Vector based upon three float components.
Vec3f scale(final float s)
this = this * s, returns this.
Vec3f normalize()
Normalize this vector in place.
float dot(final Vec3f o)
Return the dot product of this vector and the given one.
Vec3f minus(final Vec3f arg)
Returns this - arg; creates new vector.
Vec3f cross(final Vec3f arg)
Returns this cross arg; creates new vector.
Vec3f set(final Vec3f o)
this = o, returns this.
Vec3f add(final float dx, final float dy, final float dz)
this = this + { dx, dy, dz }, returns this.
4D Vector based upon four float components.
Vec4f set(final Vec4f o)
this = o, returns this.
static float[] crossVec3(final float[] r, final int r_offset, final float[] v1, final int v1_offset, final float[] v2, final int v2_offset)
cross product vec1 x vec2
static float determinant(final Vec3f a, final Vec3f b, final Vec3f c)
Return the determinant of 3 vectors.
static Vec3f midpoint(final Vec3f result, final Vec3f p1, final Vec3f p2)
Calculate the midpoint of two points.
static boolean isInTriangle3(final Vec3f a, final Vec3f b, final Vec3f c, final Vec3f p1, final Vec3f p2, final Vec3f p3, final Vec3f ac, final Vec3f ab, final Vec3f ap)
Check if one of three vertices are in triangle using barycentric coordinates computation.
static boolean testSeg2SegIntersection0(final Vert2fImmutable a, final Vert2fImmutable b, final Vert2fImmutable c, final Vert2fImmutable d)
Compute intersection between two segments.
static float[] subVec2(final float[] result, final float[] v1, final float[] v2)
Subtracts two vectors, result = v1 - v2.
static boolean testSeg2SegIntersection(final Vert2fImmutable p, final Vert2fImmutable p2, final Vert2fImmutable q, final Vert2fImmutable q2, final float epsilon, final boolean doCollinear)
Line segment intersection test.
static boolean testSeg2SegIntersection(final Vec2f p, final Vec2f p2, final Vec2f q, final Vec2f q2, final float epsilon, final boolean doCollinear)
Line segment intersection test.
static Winding getWinding(final Vert2fImmutable a, final Vert2fImmutable b, final Vert2fImmutable c)
Compute the winding of the 3 given points.
static float[] scaleVec2(final float[] result, final float[] vector, final float scale)
Scales a vector by param using given result float[], result = vector * scale.
static boolean seg2SegIntersection(final Vec3f result, final Vec2f p, final Vec2f p2, final Vec2f q, final Vec2f q2, final float epsilon, final boolean doCollinear)
Line segment intersection test and returning the intersecting point.
static boolean isCCW(final Vert2fImmutable a, final Vert2fImmutable b, final Vert2fImmutable c)
Check if points are in ccw order.
static boolean isConvex0(final List<? extends Vert2fImmutable > polyline, final boolean shortIsConvex)
Returns whether the given polyline denotes a convex shape with O(n) complexity.
static double triArea(final Vert2fImmutable a, final Vert2fImmutable b, final Vert2fImmutable c)
Computes oriented double area of a triangle, i.e.
static float normSquareVec2(final float[] vec)
Return the squared length of a vector, a.k.a the squared norm or squared magnitude
static Winding getWinding(final List<? extends Vert2fImmutable > vertices)
Compute the winding using the area(List) function over all vertices for complex shapes.
static float[] divVec2(final float[] result, final float[] vector, final float scale)
Divides a vector by param using given result float[], result = vector / scale.
static Vec3f seg2SegIntersection0(final Vec3f result, final Vert2fImmutable a, final Vert2fImmutable b, final Vert2fImmutable c, final Vert2fImmutable d)
Compute intersection between two segments.
static boolean testTri2SegIntersection(final Vert2fImmutable a, final Vert2fImmutable b, final Vert2fImmutable c, final Vert2fImmutable d, final Vert2fImmutable e)
Check if a segment intersects with a triangle using FloatUtil#EPSILON w/o considering collinear-case.
static float[] addVec2(final float[] result, final float[] v1, final float[] v2)
Adds two vectors, result = v1 + v2.
static float[] divVec2(final float[] result, final float[] vector, final float[] scale)
Divides a vector by param using given result float[], result = vector / scale.
static boolean testTri2SegIntersection0(final Vert2fImmutable a, final Vert2fImmutable b, final Vert2fImmutable c, final Vert2fImmutable d, final Vert2fImmutable e)
Check if a segment intersects with a triangle.
static float[] normalizeVec3(final float[] vector)
Normalize a vector in place.
static boolean isInTriangle3(final Vec3f a, final Vec3f b, final Vec3f c, final Vec3f p1, final Vec3f p2, final Vec3f p3, final Vec3f ac, final Vec3f ab, final Vec3f ap, final float epsilon)
Check if one of three vertices are in triangle using barycentric coordinates computation,...
static boolean isSelfIntersecting1(final List< Vertex > polyline)
Returns whether the given polyline is self-intersecting shape (crossing over) with O(n*n) complexity.
static double inCircleVal(final Vert2fImmutable a, final Vert2fImmutable b, final Vert2fImmutable c, final Vert2fImmutable d)
static boolean isInCircle(final Vert2fImmutable a, final Vert2fImmutable b, final Vert2fImmutable c, final Vert2fImmutable d)
Check if vertices in triangle circumcircle given d vertex, from paper by Guibas and Stolfi (1985).
static float normSquareVec3(final float[] vec)
Return the squared length of a vector, a.k.a the squared norm or squared magnitude
static boolean isInTriangle(final Vec3f a, final Vec3f b, final Vec3f c, final Vec3f p, final Vec3f ac, final Vec3f ab, final Vec3f ap)
Check if a vertex is in triangle using barycentric coordinates computation.
static boolean isZero(final float x, final float y, final float z)
Return true if all three vector components are zero, i.e.
static boolean isZero(final float x, final float y, final float z, final float epsilon)
Return true if all three vector components are zero, i.e.
static float normVec2(final float[] vec)
Return the length of a vector, a.k.a the norm or magnitude
static boolean testSeg2SegIntersection(final Vert2fImmutable p, final Vert2fImmutable p2, final Vert2fImmutable q, final Vert2fImmutable q2)
Line segment intersection test using FloatUtil#EPSILON w/o considering collinear-case.
static Vec3f line2PlaneIntersection(final Vec3f result, final Ray ray, final Vec4f plane, final float epsilon)
Return intersection of an infinite line with a plane if exists, otherwise null.
static boolean isVec2Zero(final Vec3f vec)
Return true if 2D vector components are zero, no FloatUtil#EPSILON is taken into consideration.
static float distVec3(final float[] v1, final float[] v2)
Return the distance between the given two points described vector v1 and v2.
static double area(final List<? extends Vert2fImmutable > vertices)
Computes the area of a list of vertices via shoelace formula.
static Vec3f line2lineIntersection0(final Vec3f result, final Vert2fImmutable a, final Vert2fImmutable b, final Vert2fImmutable c, final Vert2fImmutable d)
Compute intersection between two lines.
static boolean testTri2SegIntersection(final Vert2fImmutable a, final Vert2fImmutable b, final Vert2fImmutable c, final Vert2fImmutable d, final Vert2fImmutable e, final float epsilon, final boolean doCollinear)
Check if a segment intersects with a triangle.
static boolean isConvex1(final List< Vertex > polyline, final boolean shortIsConvex)
Returns whether the given on-curve polyline points denotes a convex shape with O(n) complexity.
static Vec4f getPlaneVec3(final Vec4f resultV4, final Vec3f normalVec3, final Vec3f pVec3)
Finds the plane equation of a plane given its normal and a point on the plane.
static float distSquareVec3(final float[] v1, final float[] v2)
Return the squared distance between the given two points described vector v1 and v2.
static float[] scaleVec2(final float[] result, final float[] vector, final float[] scale)
Scales a vector by param using given result float[], result = vector * scale.
static float normSquareVec3(final float[] vec, final int offset)
Return the squared length of a vector, a.k.a the squared norm or squared magnitude
static float[] normalizeVec3(final float[] vector, final int offset)
Normalize a vector in place.
static Vec4f getPlaneVec3(final Vec4f resultVec4, final Vec3f v1, final Vec3f v2, final Vec3f v3, final Vec3f temp1V3, final Vec3f temp2V3, final Vec3f temp3V3)
This finds the plane equation of a triangle given three vertices.
static boolean isCollinear(final Vec3f v1, final Vec3f v2, final Vec3f v3)
Check if three vertices are collinear.
Winding direction, either clockwise (CW) or counter-clockwise (CCW).