Interface Vec3Arg
- All Known Implementing Classes:
Vec3
public interface Vec3Arg
Read-only access to a
Vec3
. (native type: const Vec3)-
Method Summary
Modifier and TypeMethodDescriptionabs()
Return the absolute value of each component.Return the cross product with the argument.float
Return the dot product with the argument.float
get
(int index) Return the specified component.Return an arbitrary unit vector perpendicular to the current vector.getSign()
Return the component-wise (binary) sign.float
getX()
Return the first (X) component in single precision.float
getY()
Return the 2nd (Y) component in single precision.float
getZ()
Return the 3rd (Z) component in single precision.boolean
Test whether the specified vector lies within the specified squared distance of this one.boolean
isFinite()
Test whether the vector contains infinities or NaNs.boolean
isNan()
Test whether the vector contains NaNs.boolean
Test whether the squared length is within 10^-12 of zero.boolean
isNearZero
(float tolerance) Test whether the squared length is within the specified tolerance of zero.boolean
Test whether the vector is normalized to within a tolerance of 10^-6.boolean
isNormalized
(float tolerance) Test whether the vector is normalized to within the specified tolerance.float
length()
Return the length.float
lengthSq()
Return the squared length.Generate a unit vector with the same direction.normalizedOr
(Vec3Arg zeroValue) Return a copy of the argument if the length of the current vector is zero.void
put
(FloatBuffer storeBuffer) Write all 3 components to the specified buffer and advance the buffer's position by 3.Generate the component-wise reciprocal.float
Return the maximum component.float
Return the minimum component.void
storeFloat3
(Float3 target) Copy to aFloat3
object.swizzle
(int xi, int yi, int zi) Copy the specified components to a new vector.float[]
toArray()
Copy the components to an array.toBuffer()
Copy the components to a direct buffer.toRVec3()
Copy the components to a new location vector.
-
Method Details
-
abs
Vec3 abs()Return the absolute value of each component. The vector is unaffected.- Returns:
- a new vector with no negative components
-
cross
Return the cross product with the argument. Both vectors are unaffected.- Parameters:
rightFactor
- the vector to cross with the current one (not null, unaffected)- Returns:
- a new product vector
-
dot
Return the dot product with the argument. Both vectors are unaffected.- Parameters:
factor
- the vector to dot with the current one (not null, unaffected)- Returns:
- the dot product
-
get
float get(int index) Return the specified component. The vector is unaffected.- Parameters:
index
- 0, 1, or 2- Returns:
- the X component if index=0, the Y component if index=1, or the Z component if index=2
- Throws:
IllegalArgumentException
- if index is not 0, 1, or 2
-
getNormalizedPerpendicular
Vec3 getNormalizedPerpendicular()Return an arbitrary unit vector perpendicular to the current vector. The current vector is unaffected.- Returns:
- a new vector
-
getSign
Vec3 getSign()Return the component-wise (binary) sign. The current vector is unaffected.- Returns:
- a new vector (each component 1 or -1)
-
getX
float getX()Return the first (X) component in single precision. The vector is unaffected.- Returns:
- the component value
-
getY
float getY()Return the 2nd (Y) component in single precision. The vector is unaffected.- Returns:
- the component value
-
getZ
float getZ()Return the 3rd (Z) component in single precision. The vector is unaffected.- Returns:
- the component value
-
isFinite
boolean isFinite()Test whether the vector contains infinities or NaNs. The vector is unaffected.- Returns:
false
if one or more infinities or NaNs, otherwisetrue
-
isNan
boolean isNan()Test whether the vector contains NaNs. The vector is unaffected.- Returns:
true
if one or more NaNs, otherwisefalse
-
isNearZero
boolean isNearZero()Test whether the squared length is within 10^-12 of zero. The vector is unaffected.- Returns:
true
if nearly zero, otherwisefalse
-
isNearZero
boolean isNearZero(float tolerance) Test whether the squared length is within the specified tolerance of zero. The vector is unaffected.- Parameters:
tolerance
- the desired tolerance (≥0, default=1e-12)- Returns:
true
if nearly zero, otherwisefalse
-
isNormalized
boolean isNormalized()Test whether the vector is normalized to within a tolerance of 10^-6. The vector is unaffected.- Returns:
true
if normalized, otherwisefalse
-
isNormalized
boolean isNormalized(float tolerance) Test whether the vector is normalized to within the specified tolerance. The vector is unaffected.- Parameters:
tolerance
- the desired tolerance (≥0, default=1e-6)- Returns:
true
if normalized, otherwisefalse
-
isClose
Test whether the specified vector lies within the specified squared distance of this one. Both vectors are unaffected.- Parameters:
v2
- the vector to compare with (not null, unaffected)maxDistSq
- the maximum allowed squared distance (≥0)- Returns:
true
if within the squared distance, otherwisefalse
-
length
float length()Return the length. The vector is unaffected.- Returns:
- the length
-
lengthSq
float lengthSq()Return the squared length. The vector is unaffected.- Returns:
- the squared length
-
normalized
Vec3 normalized()Generate a unit vector with the same direction. The current vector is unaffected.- Returns:
- a new vector
-
normalizedOr
Return a copy of the argument if the length of the current vector is zero. Otherwise, generate a unit vector with the same direction as the current vector. The current vector is unaffected.- Parameters:
zeroValue
- the value to return if the length is zero (not null, unaffected)- Returns:
- a new vector
-
put
Write all 3 components to the specified buffer and advance the buffer's position by 3. The vector is unaffected.- Parameters:
storeBuffer
- the destination buffer (not null)
-
reciprocal
Vec3 reciprocal()Generate the component-wise reciprocal. The current vector is unaffected.- Returns:
- a new vector
-
reduceMax
float reduceMax()Return the maximum component. The current vector is unaffected.- Returns:
- a component value
-
reduceMin
float reduceMin()Return the minimum component. The current vector is unaffected.- Returns:
- a component value
-
storeFloat3
Copy to aFloat3
object. The vector is unaffected.- Parameters:
target
- the destination (not null, modified)
-
swizzle
Copy the specified components to a new vector. The current vector is unaffected.- Parameters:
xi
- index of the component to copy to the first (X) component of the result (0, 1, or 2)yi
- index of the component to copy to the 2nd (Y) component of the result (0, 1, or 2)zi
- index of the component to copy to the 3rd (Z) component of the result (0, 1, or 2)- Returns:
- the new vector
-
toArray
float[] toArray()Copy the components to an array. The vector is unaffected.- Returns:
- a new array with length=3
-
toBuffer
FloatBuffer toBuffer()Copy the components to a direct buffer. The vector is unaffected.- Returns:
- a new direct buffer with capacity=3
-
toRVec3
RVec3 toRVec3()Copy the components to a new location vector. The current vector is unaffected.- Returns:
- a new vector
-