Top Inners Fields Constructors Methods
com.jogamp.opengl.math

public final Class VectorUtil

extends Object
Class Inheritance
Imports
java.util.ArrayList

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum

Field Summary

Modifier and TypeField and Description
public static final float[]
public static final float[]
public static final float[]
public static final float[]
public static final float[]
public static final float[]

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static float[]

Returns:

result vector for chaining
addVec2
(final float[]
float[2] result vector, may be either v1 or v2 (in-place)
result
,
final float[]
vector 1
v1
,
final float[]
vector 2
v2
)

Adds two vectors, result = v1 + v2

public static float[]

Returns:

result vector for chaining
addVec3
(final float[]
float[3] result vector, may be either v1 or v2 (in-place)
result
,
final float[]
vector 1
v1
,
final float[]
vector 2
v2
)

Adds two vectors, result = v1 + v2

public static float
angleVec3(final float[]
vector 1
vec1
,
final float[]
vector 2
vec2
)

Return the angle between to vectors in radians

public static float

Returns:

positive area if ccw else negative area value
area
(final ArrayList<? extends Vert2fImmutable> vertices)

Computes the area of a list of vertices to check if ccw

public static boolean

Returns:

true if the points a,b,c are in a ccw order
ccw
(final Vert2fImmutable
first vertex
a
,
final Vert2fImmutable
second vertex
b
,
final Vert2fImmutable
third vertex
c
)

Check if points are in ccw order

public static float[]

Returns:

copied output vector for chaining
copyVec2
(final float[]
output vector
dst
,
final int
offset of dst in array
dstOffset
,
final float[]
input vector
src
,
final int
offset of src in array
srcOffset
)

Copies a vector of length 2

public static float[]

Returns:

copied output vector for chaining
copyVec3
(final float[]
output vector
dst
,
final int
offset of dst in array
dstOffset
,
final float[]
input vector
src
,
final int
offset of src in array
srcOffset
)

Copies a vector of length 3

public static float[]

Returns:

copied output vector for chaining
copyVec4
(final float[]
output vector
dst
,
final int
offset of dst in array
dstOffset
,
final float[]
input vector
src
,
final int
offset of src in array
srcOffset
)

Copies a vector of length 4

public static float
cosAngleVec3(final float[]
vector 1
vec1
,
final float[]
vector 2
vec2
)

Return the cosines of the angle between to vectors

public static float[]

Returns:

the resulting vector
crossVec3
(final float[] result, final float[]
vector 1
v1
,
final float[]
vector 2
v2
)

cross product vec1 x vec2

public static float[]

Returns:

the resulting vector
crossVec3
(final float[] r, final int r_offset, final float[]
vector 1
v1
,
final int v1_offset, final float[]
vector 2
v2
,
final int v2_offset)

cross product vec1 x vec2

public static float

Returns:

the determinant value
determinantVec3
(final float[]
vector 1
a
,
final float[]
vector 2
b
,
final float[]
vector 3
c
)

Return the determinant of 3 vectors

public static float
distSquareVec3(final float[] v1, final float[] v2)

Return the squared distance between the given two points described vector v1 and v2.

public static float
distVec3(final float[] v1, final float[] v2)

Return the distance between the given two points described vector v1 and v2.

public static float[]

Returns:

result vector for chaining
divVec2
(final float[]
vector for the result, may be vector (in-place)
result
,
final float[]
input vector
vector
,
final float
single scale constant for all vector components
scale
)

Divides a vector by param using given result float[], result = vector / scale

public static float[]

Returns:

result vector for chaining
divVec2
(final float[]
vector for the result, may be vector (in-place)
result
,
final float[]
input vector
vector
,
final float[]
2 component scale constant for each vector component
scale
)

Divides a vector by param using given result float[], result = vector / scale

public static float[]

Returns:

result vector for chaining
divVec3
(final float[]
vector for the result, may be vector (in-place)
result
,
final float[]
input vector
vector
,
final float
single scale constant for all vector components
scale
)

Divides a vector by param using given result float[], result = vector / scale

public static float[]

Returns:

result vector for chaining
divVec3
(final float[]
vector for the result, may be vector (in-place)
result
,
final float[]
input vector
vector
,
final float[]
3 component scale constant for each vector component
scale
)

Divides a vector by param using given result float[], result = vector / scale

public static float

Returns:

the dot product as float
dotVec3
(final float[]
vector 1
vec1
,
final float[]
vector 2
vec2
)

Return the dot product of two points

public static float[]

Returns:

result for chaining
getNormalVec2
(final float[]
vec2 result for normal
result
,
final float[]
vec2
v1
,
final float[]
vec2
v2
)

public static float[]

Returns:

result for chaining
getNormalVec3
(final float[]
vec3 result for normal
result
,
final float[]
vec3
v1
,
final float[]
vec3
v2
,
final float[]
vec3
v3
,
final float[]
temp vec3
tmp1Vec3
,
final float[]
temp vec3
tmp2Vec3
)

Returns the 3d surface normal of a triangle given three vertices.

public static float[]

Returns:

result for chaining
getPlaneVec3
(final float[]
vec4 plane equation
resultV4
,
final float[] normalVec3, final float[] pVec3)

Finds the plane equation of a plane given its normal and a point on the plane.

public static float[]

Returns:

result for chaining
getPlaneVec3
(final float[]
vec4 plane equation
resultVec4
,
final float[]
vec3
v1
,
final float[]
vec3
v2
,
final float[]
vec3
v3
,
final float[] temp1V3, final float[] temp2V3)

This finds the plane equation of a triangle given three vertices.

public static VectorUtil.Winding

Returns:

Winding
getWinding
(final Vert2fImmutable
first vertex
a
,
final Vert2fImmutable
second vertex
b
,
final Vert2fImmutable
third vertex
c
)

Compute the winding of given points

public static VectorUtil.Winding

Returns:

CCW or CW Winding
getWinding
(final ArrayList<? extends Vert2fImmutable>
array of Vertices
vertices
)

Compute the general winding of the vertices

public static boolean

Returns:

true if collinear, false otherwise
isCollinearVec3
(final float[]
vertex 1
v1
,
final float[]
vertex 2
v2
,
final float[]
vertex 3
v3
)

Check if three vertices are colliniear

public static boolean

Returns:

true if the vertex d is inside the circle defined by the vertices a, b, c. from paper by Guibas and Stolfi (1985).
isInCircleVec2
(final Vert2fImmutable
triangle vertex 1
a
,
final Vert2fImmutable
triangle vertex 2
b
,
final Vert2fImmutable
triangle vertex 3
c
,
final Vert2fImmutable
vertex in question
d
)

Check if vertices in triangle circumcircle

public static boolean

Returns:

true if p is in triangle (a, b, c), false otherwise.
isInTriangleVec3
(final float[]
first triangle vertex
a
,
final float[]
second triangle vertex
b
,
final float[]
third triangle vertex
c
,
final float[]
the vertex in question
p
,
final float[] ac, final float[] ab, final float[] ap)

Check if a vertex is in triangle using barycentric coordinates computation.

public static boolean
isVec2Equal(final float[] vec1, final int vec1Offset, final float[] vec2, final int vec2Offset)

Return true if both vectors are equal w/o regarding an epsilon.

public static boolean
isVec2Equal(final float[] vec1, final int vec1Offset, final float[] vec2, final int vec2Offset, final float epsilon)

Return true if both vectors are equal, i.e. their absolute delta < epsilon.

public static boolean
isVec2Zero(final float[] vec, final int vecOffset)

Return true if vector is zero, no FloatUtil#EPSILON is taken into consideration.

public static boolean
isVec2Zero(final float[] vec, final int vecOffset, final float epsilon)

Return true if vector is zero, i.e. it's absolute components < epsilon.

public static boolean
isVec3Equal(final float[] vec1, final int vec1Offset, final float[] vec2, final int vec2Offset)

Return true if both vectors are equal w/o regarding an epsilon.

public static boolean
isVec3Equal(final float[] vec1, final int vec1Offset, final float[] vec2, final int vec2Offset, final float epsilon)

Return true if both vectors are equal, i.e. their absolute delta < epsilon.

public static boolean

Returns:

true if p1 or p2 or p3 is in triangle (a, b, c), false otherwise.
isVec3InTriangle3
(final float[]
first triangle vertex
a
,
final float[]
second triangle vertex
b
,
final float[]
third triangle vertex
c
,
final float[]
the vertex in question
p1
,
final float[]
the vertex in question
p2
,
final float[]
the vertex in question
p3
,
final float[] tmpAC, final float[] tmpAB, final float[] tmpAP)

Check if one of three vertices are in triangle using barycentric coordinates computation.

public static boolean

Returns:

true if p1 or p2 or p3 is in triangle (a, b, c), false otherwise.
isVec3InTriangle3
(final float[]
first triangle vertex
a
,
final float[]
second triangle vertex
b
,
final float[]
third triangle vertex
c
,
final float[]
the vertex in question
p1
,
final float[]
the vertex in question
p2
,
final float[]
the vertex in question
p3
,
final float[] tmpAC, final float[] tmpAB, final float[] tmpAP, final float epsilon)

Check if one of three vertices are in triangle using barycentric coordinates computation, using given epsilon for comparison.

public static boolean
isVec3Zero(final float[] vec, final int vecOffset)

Return true if vector is zero, no FloatUtil#EPSILON is taken into consideration.

public static boolean
isVec3Zero(final float[] vec, final int vecOffset, final float epsilon)

Return true if vector is zero, i.e. it's absolute components < epsilon.

public static boolean
isZero(final float x, final float y, final float epsilon)

Return true if all two vector components are zero, i.e. it's their absolute value < epsilon.

public 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. it's their absolute value < epsilon.

public static float[]

Returns:

the intersection coordinates if the lines intersect, otherwise returns null
line2lineIntersection
(final float[] result, final Vert2fImmutable
vertex 1 of first line
a
,
final Vert2fImmutable
vertex 2 of first line
b
,
final Vert2fImmutable
vertex 1 of second line
c
,
final Vert2fImmutable
vertex 2 of second line
d
)

Compute intersection between two lines

public static float[]

Returns:

resulting intersecting if exists, otherwise null
line2PlaneIntersection
(final float[]
vec3 result buffer for intersecting coords
result
,
final Ray
here representing an infinite line, origin and direction.
ray
,
final float[]
vec4 plane equation
plane
,
final float epsilon)

Return intersection of an infinite line with a plane if exists, otherwise null.

public static float

Returns:

midpoint
mid
(final float
first value
p1
,
final float
second vale
p2
)

Calculate the midpoint of two values

public static float[]

Returns:

midpoint
midVec3
(final float[] result, final float[]
first point vector
p1
,
final float[]
second point vector
p2
)

Calculate the midpoint of two points

public static float[]

Returns:

result
mulColMat4Vec3
(final float[] result, final float[]
column matrix (4x4)
colMatrix
,
final float[]
vector(x,y,z)
vec
)

Multiplication of column-major 4x4 matrix with vector

public static float[]

Returns:

result
mulRowMat4Vec3
(final float[] result, final float[]
column matrix (4x4)
rawMatrix
,
final float[]
vector(x,y,z)
vec
)

Matrix Vector multiplication

public static float[]

Returns:

normalized output vector
normalizeVec2
(final float[]
output vector, may be vector (in-place)
result
,
final float[]
input vector
vector
)

Normalize a vector

public static float[]

Returns:

normalized output vector
normalizeVec2
(final float[]
input vector
vector
)

Normalize a vector in place

public static float[]

Returns:

normalized output vector
normalizeVec3
(final float[]
output vector, may be vector (in-place)
result
,
final float[]
input vector
vector
)

Normalize a vector

public static float[]

Returns:

normalized output vector
normalizeVec3
(final float[]
input vector
vector
)

Normalize a vector in place

public static float[]

Returns:

normalized output vector
normalizeVec3
(final float[]
input vector
vector
,
final int offset)

Normalize a vector in place

public static float
normSquareVec2(final float[] vec)

Return the squared length of a vector, a.k.a the squared norm or squared magnitude

public static float
normSquareVec2(final float[] vec, final int offset)

Return the squared length of a vector, a.k.a the squared norm or squared magnitude

public static float
normSquareVec3(final float[] vec)

Return the squared length of a vector, a.k.a the squared norm or squared magnitude

public 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

public static float
normVec2(final float[] vec)

Return the length of a vector, a.k.a the norm or magnitude

public static float
normVec3(final float[] vec)

Return the length of a vector, a.k.a the norm or magnitude

public static float[]

Returns:

result vector for chaining
scaleVec2
(final float[]
vector for the result, may be vector (in-place)
result
,
final float[]
input vector
vector
,
final float
single scale constant for all vector components
scale
)

Scales a vector by param using given result float[], result = vector * scale

public static float[]

Returns:

result vector for chaining
scaleVec2
(final float[]
vector for the result, may be vector (in-place)
result
,
final float[]
input vector
vector
,
final float[]
2 component scale constant for each vector component
scale
)

Scales a vector by param using given result float[], result = vector * scale

public static float[]

Returns:

result vector for chaining
scaleVec3
(final float[]
vector for the result, may be vector (in-place)
result
,
final float[]
input vector
vector
,
final float
single scale constant for all vector components
scale
)

Scales a vector by param using given result float[], result = vector * scale

public static float[]

Returns:

result vector for chaining
scaleVec3
(final float[]
vector for the result, may be vector (in-place)
result
,
final float[]
input vector
vector
,
final float[]
3 component scale constant for each vector component
scale
)

Scales a vector by param using given result float[], result = vector * scale

public static float[]

Returns:

the intersection coordinates if the segments intersect, otherwise returns null
seg2SegIntersection
(final float[] result, final Vert2fImmutable
vertex 1 of first segment
a
,
final Vert2fImmutable
vertex 2 of first segment
b
,
final Vert2fImmutable
vertex 1 of second segment
c
,
final Vert2fImmutable
vertex 2 of second segment
d
)

Compute intersection between two segments

public static float[]

Returns:

result vector for chaining
subVec2
(final float[]
float[2] result vector, may be either v1 or v2 (in-place)
result
,
final float[]
vector 1
v1
,
final float[]
vector 2
v2
)

Subtracts two vectors, result = v1 - v2

public static float[]

Returns:

result vector for chaining
subVec3
(final float[]
float[3] result vector, may be either v1 or v2 (in-place)
result
,
final float[]
vector 1
v1
,
final float[]
vector 2
v2
)

Subtracts two vectors, result = v1 - v2

public static boolean

Returns:

true if the segments intersect, otherwise returns false
testSeg2SegIntersection
(final Vert2fImmutable
vertex 1 of first segment
a
,
final Vert2fImmutable
vertex 2 of first segment
b
,
final Vert2fImmutable
vertex 1 of second segment
c
,
final Vert2fImmutable
vertex 2 of second segment
d
)

Compute intersection between two segments

public static boolean

Returns:

true if the segments intersect, otherwise returns false
testSeg2SegIntersection
(final Vert2fImmutable
vertex 1 of first segment
a
,
final Vert2fImmutable
vertex 2 of first segment
b
,
final Vert2fImmutable
vertex 1 of second segment
c
,
final Vert2fImmutable
vertex 2 of second segment
d
,
final float epsilon)

Compute intersection between two segments, using given epsilon for comparison.

public static boolean

Returns:

true if the segment intersects at least one segment of the triangle, false otherwise
testTri2SegIntersection
(final Vert2fImmutable
vertex 1 of the triangle
a
,
final Vert2fImmutable
vertex 2 of the triangle
b
,
final Vert2fImmutable
vertex 3 of the triangle
c
,
final Vert2fImmutable
vertex 1 of first segment
d
,
final Vert2fImmutable
vertex 2 of first segment
e
)

Check if a segment intersects with a triangle

public static boolean

Returns:

true if the segment intersects at least one segment of the triangle, false otherwise
testTri2SegIntersection
(final Vert2fImmutable
vertex 1 of the triangle
a
,
final Vert2fImmutable
vertex 2 of the triangle
b
,
final Vert2fImmutable
vertex 3 of the triangle
c
,
final Vert2fImmutable
vertex 1 of first segment
d
,
final Vert2fImmutable
vertex 2 of first segment
e
,
final float epsilon)

Check if a segment intersects with a triangle, using given epsilon for comparison.

public static float

Returns:

compute twice the area of the oriented triangle (a,b,c), the area is positive if the triangle is oriented counterclockwise.
triAreaVec2
(final Vert2fImmutable
first vertex
a
,
final Vert2fImmutable
second vertex
b
,
final Vert2fImmutable
third vertex
c
)

Computes oriented area of a triangle

public static float

Returns:

compute twice the area of the oriented triangle (a,b,c), the area is positive if the triangle is oriented counterclockwise.
triAreaVec2
(final float[]
first vertex
A
,
final float[]
second vertex
B
,
final float[]
third vertex
C
)

Computes oriented area of a triangle

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait