public class VectorUtil extends Object
Modifier and Type | Class and Description |
---|---|
static class |
VectorUtil.Winding |
Modifier and Type | Field and Description |
---|---|
static int |
COLLINEAR |
Constructor and Description |
---|
VectorUtil() |
Modifier and Type | Method and Description |
---|---|
static float |
area(ArrayList<? extends Vert2fImmutable> vertices)
Computes the area of a list of vertices to check if ccw
|
static boolean |
ccw(Vert2fImmutable a,
Vert2fImmutable b,
Vert2fImmutable c)
Check if points are in ccw order
|
static boolean |
checkCollinear(float[] v1,
float[] v2,
float[] v3)
Check if three vertices are colliniear
|
static boolean |
checkEquality(float[] v1,
float[] v2)
Check equality of 2 vec3 vectors
|
static boolean |
checkEqualityVec2(float[] v1,
float[] v2)
Check equality of 2 vec2 vectors
|
static float[] |
colMatrixVectorMult(float[] colMatrix,
float[] vec)
Column Matrix Vector multiplication
|
static float |
computeDeterminant(float[] a,
float[] b,
float[] c)
Compute the determinant of 3 vectors
|
static float |
computeLength(float[] p0,
float[] point)
Compute distance between 2 points
|
static float[] |
computeVector(float[] v1,
float[] v2)
Compute Vector
|
static float[] |
cross(float[] vec1,
float[] vec2)
cross product vec1 x vec2
|
static float |
dot(float[] vec1,
float[] vec2)
compute the dot product of two points
|
static VectorUtil.Winding |
getWinding(ArrayList<? extends Vert2fImmutable> vertices)
Compute the general winding of the vertices
|
static VectorUtil.Winding |
getWinding(Vert2fImmutable a,
Vert2fImmutable b,
Vert2fImmutable c)
Compute the winding of given points
|
static boolean |
inCircle(Vert2fImmutable a,
Vert2fImmutable b,
Vert2fImmutable c,
Vert2fImmutable d)
Check if vertices in triangle circumcircle
|
static float[] |
line2lineIntersection(Vert2fImmutable a,
Vert2fImmutable b,
Vert2fImmutable c,
Vert2fImmutable d)
Compute intersection between two lines
|
static float[] |
mid(float[] p1,
float[] p2)
Calculate the midpoint of two points
|
static float |
mid(float p1,
float p2)
Calculate the midpoint of two values
|
static float |
norm(float[] vec)
Compute the norm of a vector
|
static float[] |
normalize(float[] vector)
Normalize a vector
|
static float[] |
rowMatrixVectorMult(float[] rawMatrix,
float[] vec)
Matrix Vector multiplication
|
static float[] |
scale(float[] vector,
float scale)
Deprecated.
|
static float[] |
scale(float[] result,
float[] vector,
float scale)
Scales a vector by param using given result float[]
|
static float[] |
scale(float[] result,
float[] vector,
float[] scale)
Scales a vector by param using given result float[]
|
static float[] |
seg2SegIntersection(Vert2fImmutable a,
Vert2fImmutable b,
Vert2fImmutable c,
Vert2fImmutable d)
Compute intersection between two segments
|
static boolean |
tri2SegIntersection(Vert2fImmutable a,
Vert2fImmutable b,
Vert2fImmutable c,
Vert2fImmutable d,
Vert2fImmutable e)
Check if a segment intersects with a triangle
|
static float |
triArea(Vert2fImmutable a,
Vert2fImmutable b,
Vert2fImmutable c)
Computes oriented area of a triangle
|
static float[] |
vectorAdd(float[] v1,
float[] v2)
Adds to vectors
|
static boolean |
vertexInTriangle(float[] a,
float[] b,
float[] c,
float[] p)
Check if a vertex is in triangle using
barycentric coordinates computation.
|
public static final int COLLINEAR
public static float dot(float[] vec1, float[] vec2)
vec1
- vector 1vec2
- vector 2public static float[] normalize(float[] vector)
vector
- input vectorpublic static float[] scale(float[] vector, float scale)
scale(float[], float[], float)
vector
- input vectorscale
- constant to scale bypublic static float[] scale(float[] result, float[] vector, float scale)
result
- vector for the resultvector
- input vectorscale
- single scale constant for all vector componentspublic static float[] scale(float[] result, float[] vector, float[] scale)
result
- vector for the resultvector
- input vectorscale
- 3 component scale constant for each vector componentpublic static float[] vectorAdd(float[] v1, float[] v2)
v1
- vector 1v2
- vector 2public static float[] cross(float[] vec1, float[] vec2)
vec1
- vector 1vec2
- vecttor 2public static float[] colMatrixVectorMult(float[] colMatrix, float[] vec)
colMatrix
- column matrix (4x4)vec
- vector(x,y,z)public static float[] rowMatrixVectorMult(float[] rawMatrix, float[] vec)
rawMatrix
- column matrix (4x4)vec
- vector(x,y,z)public static float mid(float p1, float p2)
p1
- first valuep2
- second valepublic static float[] mid(float[] p1, float[] p2)
p1
- first pointp2
- second pointpublic static float norm(float[] vec)
vec
- vectorpublic static float computeLength(float[] p0, float[] point)
p0
- a ref point on the linevec
- vector representing the direction of the linepoint
- the point to compute the relative distance ofpublic static boolean checkEquality(float[] v1, float[] v2)
v1
- vertex 1v2
- vertex 2public static boolean checkEqualityVec2(float[] v1, float[] v2)
v1
- vertex 1v2
- vertex 2public static float computeDeterminant(float[] a, float[] b, float[] c)
a
- vector 1b
- vector 2c
- vector 3public static boolean checkCollinear(float[] v1, float[] v2, float[] v3)
v1
- vertex 1v2
- vertex 2v3
- vertex 3public static float[] computeVector(float[] v1, float[] v2)
v1
- vertex 1v2
- vertex2 2public static boolean inCircle(Vert2fImmutable a, Vert2fImmutable b, Vert2fImmutable c, Vert2fImmutable d)
a
- triangle vertex 1b
- triangle vertex 2c
- triangle vertex 3d
- vertex in questionpublic static float triArea(Vert2fImmutable a, Vert2fImmutable b, Vert2fImmutable c)
a
- first vertexb
- second vertexc
- third vertexpublic static boolean vertexInTriangle(float[] a, float[] b, float[] c, float[] p)
a
- first triangle vertexb
- second triangle vertexc
- third triangle vertexp
- the vertex in questionpublic static boolean ccw(Vert2fImmutable a, Vert2fImmutable b, Vert2fImmutable c)
a
- first vertexb
- second vertexc
- third vertexpublic static VectorUtil.Winding getWinding(Vert2fImmutable a, Vert2fImmutable b, Vert2fImmutable c)
a
- first vertexb
- second vertexc
- third vertexpublic static float area(ArrayList<? extends Vert2fImmutable> vertices)
vertices
- public static VectorUtil.Winding getWinding(ArrayList<? extends Vert2fImmutable> vertices)
vertices
- array of VerticesVectorUtil.Winding
public static float[] seg2SegIntersection(Vert2fImmutable a, Vert2fImmutable b, Vert2fImmutable c, Vert2fImmutable d)
a
- vertex 1 of first segmentb
- vertex 2 of first segmentc
- vertex 1 of second segmentd
- vertex 2 of second segmentpublic static float[] line2lineIntersection(Vert2fImmutable a, Vert2fImmutable b, Vert2fImmutable c, Vert2fImmutable d)
a
- vertex 1 of first lineb
- vertex 2 of first linec
- vertex 1 of second lined
- vertex 2 of second linepublic static boolean tri2SegIntersection(Vert2fImmutable a, Vert2fImmutable b, Vert2fImmutable c, Vert2fImmutable d, Vert2fImmutable e)
a
- vertex 1 of the triangleb
- vertex 2 of the trianglec
- vertex 3 of the triangled
- vertex 1 of first segmente
- vertex 2 of first segmentCopyright 2010 JogAmp Community.