|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objecttoxi.geom.Vec3D
public class Vec3D

Comprehensive 3D vector class with additional basic intersection and collision detection features.
| Nested Class Summary | |
|---|---|
static class |
Vec3D.Axis
|
| Field Summary | |
|---|---|
static ReadonlyVec3D |
MAX_VALUE
Defines vector with all coords set to Float.MAX_VALUE. |
static ReadonlyVec3D |
MIN_VALUE
Defines vector with all coords set to Float.MIN_VALUE. |
float |
x
X coordinate. |
static ReadonlyVec3D |
X_AXIS
Defines positive X axis. |
float |
y
Y coordinate. |
static ReadonlyVec3D |
Y_AXIS
Defines positive Y axis. |
float |
z
Z coordinate. |
static ReadonlyVec3D |
Z_AXIS
Defines positive Z axis. |
static ReadonlyVec3D |
ZERO
Defines the zero vector. |
| Constructor Summary | |
|---|---|
Vec3D()
Creates a new zero vector. |
|
Vec3D(float x,
float y,
float z)
Creates a new vector with the given coordinates. |
|
Vec3D(ReadonlyVec3D v)
Creates a new vector with the coordinates of the given vector. |
|
| Method Summary | |
|---|---|
Vec3D |
abs()
Abs. |
Vec3D |
add(float a,
float b,
float c)
Adds vector {a,b,c} and returns result as new vector. |
Vec3D |
add(ReadonlyVec3D v)
|
Vec3D |
add(Vec3D v)
Add vector v and returns result as new vector. |
ReadonlyVec3D |
addSelf(float a,
float b,
float c)
Adds vector {a,b,c} and overrides coordinates with result. |
Vec3D |
addSelf(Vec3D v)
Adds vector v and overrides coordinates with result. |
float |
angleBetween(ReadonlyVec3D v)
Computes the angle between this vector and vector V. |
float |
angleBetween(ReadonlyVec3D v,
boolean forceNormalize)
Computes the angle between this vector and vector V. |
ReadonlyVec3D |
clear()
Sets all vector components to 0. |
int |
compareTo(ReadonlyVec3D v)
Compares the length of the vector with another one. |
Vec3D |
constrain(AABB box)
Forcefully fits the vector in the given AABB. |
Vec3D |
constrain(Vec3D min,
Vec3D max)
Forcefully fits the vector in the given AABB specified by the 2 given points. |
Vec3D |
copy()
Copy. |
Vec3D |
cross(ReadonlyVec3D v)
Calculates cross-product with vector v. |
Vec3D |
cross(Vec3D v)
|
Vec3D |
crossInto(ReadonlyVec3D v,
Vec3D result)
Calculates cross-product with vector v. |
Vec3D |
crossSelf(Vec3D v)
Calculates cross-product with vector v. |
float |
distanceTo(ReadonlyVec3D v)
Calculates distance to another vector. |
float |
distanceToSquared(ReadonlyVec3D v)
Calculates the squared distance to another vector. |
float |
dot(ReadonlyVec3D v)
Computes the scalar product (dot product) with the given vector. |
float |
dot(Vec3D v)
|
boolean |
equals(java.lang.Object obj)
|
boolean |
equalsWithTolerance(ReadonlyVec3D v,
float tolerance)
Compares this vector with the one given. |
Vec3D |
floor()
Replaces the vector components with integer values of their current values. |
Vec3D |
frac()
Replaces the vector components with the fractional part of their current values. |
static Vec3D |
fromXYTheta(float theta)
Creates a new vector from the given angle in the XY plane. |
static Vec3D |
fromXZTheta(float theta)
Creates a new vector from the given angle in the XZ plane. |
static Vec3D |
fromYZTheta(float theta)
Creates a new vector from the given angle in the YZ plane. |
Vec3D |
getAbs()
Gets the abs. |
float |
getComponent(int id)
|
float |
getComponent(Vec3D.Axis id)
|
Vec3D |
getConstrained(AABB box)
Creates a copy of the vector which forcefully fits in the given AABB. |
Vec3D |
getFloored()
Creates a new vector whose components are the integer value of their current values. |
Vec3D |
getFrac()
Creates a new vector whose components are the fractional part of their current values. |
Vec3D |
getInverted()
Scales vector uniformly by factor -1 ( v = -v ). |
Vec3D |
getLimited(float lim)
Creates a copy of the vector with its magnitude limited to the length given. |
Vec3D |
getNormalized()
Produces the normalized version as a new vector. |
Vec3D |
getNormalizedTo(float len)
Produces a new vector normalized to the given length. |
Vec3D |
getReciprocal()
Returns a multiplicative inverse copy of the vector. |
Vec3D |
getReflected(ReadonlyVec3D normal)
|
Vec3D |
getRotatedAroundAxis(ReadonlyVec3D axis,
float theta)
Gets the rotated around axis. |
Vec3D |
getRotatedX(float theta)
Creates a new vector rotated by the given angle around the X axis. |
Vec3D |
getRotatedY(float theta)
Creates a new vector rotated by the given angle around the Y axis. |
Vec3D |
getRotatedZ(float theta)
Creates a new vector rotated by the given angle around the Z axis. |
Vec3D |
getSignum()
Creates a new vector in which all components are replaced with the signum of their original values. |
int |
hashCode()
Returns a unique code for this vector object based on it's values. |
float |
headingXY()
Computes the vector's direction in the XY plane (for example for 2D points). |
float |
headingXZ()
Computes the vector's direction in the XZ plane. |
float |
headingYZ()
Computes the vector's direction in the YZ plane. |
ReadonlyVec3D |
immutable()
|
Vec3D |
interpolateTo(ReadonlyVec3D v,
float f)
Interpolates the vector towards the given target vector, using linear interpolation. |
Vec3D |
interpolateTo(ReadonlyVec3D v,
float f,
InterpolateStrategy s)
Interpolates the vector towards the given target vector, using the given InterpolateStrategy. |
Vec3D |
interpolateTo(Vec3D v,
float f)
|
Vec3D |
interpolateTo(Vec3D v,
float f,
InterpolateStrategy s)
|
Vec3D |
interpolateToSelf(ReadonlyVec3D v,
float f)
Interpolates the vector towards the given target vector, using linear interpolation. |
Vec3D |
interpolateToSelf(ReadonlyVec3D v,
float f,
InterpolateStrategy s)
Interpolates the vector towards the given target vector, using the given InterpolateStrategy. |
Vec3D |
invert()
Scales vector uniformly by factor -1 ( v = -v ), overrides coordinates with result. |
boolean |
isInAABB(AABB box)
Checks if the point is inside the given AABB. |
boolean |
isInAABB(Vec3D boxOrigin,
Vec3D boxExtent)
Checks if the point is inside the given axis-aligned bounding box. |
boolean |
isMajorAxis(float tol)
Checks if the vector is parallel with either the X or Y axis (any direction). |
boolean |
isZeroVector()
Checks if vector has a magnitude equals or close to zero (tolerance used is MathUtils.EPS). |
Vec3D |
jitter(float j)
Add random jitter to the vector in the range -j ... |
Vec3D |
jitter(float jx,
float jy,
float jz)
Adds random jitter to the vector in the range -j ... |
Vec3D |
jitter(java.util.Random rnd,
float j)
|
Vec3D |
jitter(java.util.Random rnd,
float jx,
float jy,
float jz)
|
Vec3D |
jitter(java.util.Random rnd,
Vec3D jitterVec)
|
Vec3D |
jitter(Vec3D jitterVec)
Adds random jitter to the vector in the range defined by the given vector components and using the default Random generator of
MathUtils. |
Vec3D |
limit(float lim)
Limits the vector's magnitude to the length given. |
float |
magnitude()
Calculates the magnitude/eucledian length of the vector. |
float |
magSquared()
Calculates only the squared magnitude/length of the vector. |
static Vec3D |
max(ReadonlyVec3D a,
ReadonlyVec3D b)
Constructs a new vector consisting of the largest components of both vectors. |
Vec3D |
maxSelf(ReadonlyVec3D b)
Max self. |
static Vec3D |
min(ReadonlyVec3D a,
ReadonlyVec3D b)
Constructs a new vector consisting of the smallest components of both vectors. |
Vec3D |
minSelf(ReadonlyVec3D b)
Min self. |
Vec3D |
modSelf(float base)
Applies a uniform modulo operation to the vector, using the same base for all components. |
Vec3D |
modSelf(float bx,
float by,
float bz)
Calculates modulo operation for each vector component separately. |
Vec3D |
normalize()
Normalizes the vector so that its magnitude = 1. |
Vec3D |
normalizeTo(float len)
Normalizes the vector to the given length. |
static Vec3D |
randomVector()
Static factory method. |
static Vec3D |
randomVector(java.util.Random rnd)
Static factory method. |
Vec3D |
reciprocal()
Replaces the vector components with their multiplicative inverse. |
Vec3D |
reflect(ReadonlyVec3D normal)
|
Vec3D |
rotateAroundAxis(ReadonlyVec3D axis,
float theta)
Rotates the vector around the giving axis. |
Vec3D |
rotateX(float theta)
Rotates the vector by the given angle around the X axis. |
Vec3D |
rotateY(float theta)
Rotates the vector by the given angle around the Y axis. |
Vec3D |
rotateZ(float theta)
Rotates the vector by the given angle around the Z axis. |
Vec3D |
roundToAxis()
Rounds the vector to the closest major axis. |
Vec3D |
scale(float s)
Scales vector uniformly and returns result as new vector. |
Vec3D |
scale(float a,
float b,
float c)
Scales vector non-uniformly and returns result as new vector. |
Vec3D |
scale(ReadonlyVec3D s)
Scales vector non-uniformly by vector v and returns result as new vector. |
Vec3D |
scale(Vec3D s)
|
Vec3D |
scaleSelf(float s)
Scales vector uniformly and overrides coordinates with result. |
Vec3D |
scaleSelf(float a,
float b,
float c)
Scales vector non-uniformly by vector {a,b,c} and overrides coordinates with result. |
Vec3D |
scaleSelf(Vec3D s)
Scales vector non-uniformly by vector v and overrides coordinates with result. |
Vec3D |
set(float x,
float y,
float z)
Overrides coordinates with the given values. |
Vec3D |
set(ReadonlyVec3D v)
|
Vec3D |
set(Vec3D v)
Overrides coordinates with the ones of the given vector. |
Vec3D |
setComponent(int id,
float val)
|
Vec3D |
setComponent(Vec3D.Axis id,
float val)
|
Vec3D |
setXY(Vec2D v)
Overrides XY coordinates with the ones of the given 2D vector. |
Vec3D |
shuffle(int iterations)
|
Vec3D |
signum()
Replaces all vector components with the signum of their original values. |
Vec3D |
sub(float a,
float b,
float c)
Subtracts vector {a,b,c} and returns result as new vector. |
Vec3D |
sub(ReadonlyVec3D v)
Subtracts vector v and returns result as new vector. |
Vec3D |
sub(Vec3D v)
|
Vec3D |
subSelf(float a,
float b,
float c)
Subtracts vector {a,b,c} and overrides coordinates with result. |
Vec3D |
subSelf(Vec3D v)
Subtracts vector v and overrides coordinates with result. |
Vec2D |
to2DXY()
Creates a new 2D vector of the XY components. |
Vec2D |
to2DXZ()
Creates a new 2D vector of the XZ components. |
Vec2D |
to2DYZ()
Creates a new 2D vector of the YZ components. |
float[] |
toArray()
|
float[] |
toArray4(float w)
|
Vec3D |
toCartesian()
Converts the spherical vector back into cartesian coordinates. |
Vec3D |
toSpherical()
Converts the vector into spherical coordinates. |
java.lang.String |
toString()
|
float |
x()
|
float |
y()
|
float |
z()
|
| Methods inherited from class java.lang.Object |
|---|
getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final ReadonlyVec3D X_AXIS
public static final ReadonlyVec3D Y_AXIS
public static final ReadonlyVec3D Z_AXIS
public static final ReadonlyVec3D ZERO
public static final ReadonlyVec3D MIN_VALUE
public static final ReadonlyVec3D MAX_VALUE
public float x
public float y
public float z
| Constructor Detail |
|---|
public Vec3D()
public Vec3D(float x,
float y,
float z)
x - the xy - the yz - the zpublic Vec3D(ReadonlyVec3D v)
v - vector to be copied| Method Detail |
|---|
public static final Vec3D fromXYTheta(float theta)
theta - the theta
public static final Vec3D fromXZTheta(float theta)
theta - the theta
public static final Vec3D fromYZTheta(float theta)
theta - the theta
public static final Vec3D max(ReadonlyVec3D a,
ReadonlyVec3D b)
b - the ba - the a
public static final Vec3D min(ReadonlyVec3D a,
ReadonlyVec3D b)
b - comparing vectora - the a
public static final Vec3D randomVector()
MathUtils class.
public static final Vec3D randomVector(java.util.Random rnd)
rnd - the rnd
public final Vec3D abs()
public final Vec3D add(float a,
float b,
float c)
ReadonlyVec3D
add in interface ReadonlyVec3Da - X coordinateb - Y coordinatec - Z coordinate
public Vec3D add(ReadonlyVec3D v)
add in interface ReadonlyVec3Dpublic final Vec3D add(Vec3D v)
ReadonlyVec3D
add in interface ReadonlyVec3Dv - vector to add
public final ReadonlyVec3D addSelf(float a,
float b,
float c)
a - X coordinateb - Y coordinatec - Z coordinate
public final Vec3D addSelf(Vec3D v)
v - vector to add
public final float angleBetween(ReadonlyVec3D v)
ReadonlyVec3DReadonlyVec3D.angleBetween(ReadonlyVec3D, boolean)
angleBetween in interface ReadonlyVec3Dv - vector
public final float angleBetween(ReadonlyVec3D v,
boolean forceNormalize)
ReadonlyVec3D
angleBetween in interface ReadonlyVec3Dv - vectorforceNormalize - true, if normalized versions of the vectors are to be used
(Note: only copies will be used, original vectors will not be
altered by this method)
public final ReadonlyVec3D clear()
public int compareTo(ReadonlyVec3D v)
ReadonlyVec3D
compareTo in interface java.lang.Comparable<ReadonlyVec3D>compareTo in interface ReadonlyVec3Dv - vector to compare with
public final Vec3D constrain(AABB box)
box - the box
public final Vec3D constrain(Vec3D min,
Vec3D max)
min - max -
public Vec3D copy()
ReadonlyVec3D
copy in interface ReadonlyVec3Dpublic final Vec3D cross(ReadonlyVec3D v)
ReadonlyVec3D
cross in interface ReadonlyVec3Dv - vector to cross
public final Vec3D cross(Vec3D v)
public final Vec3D crossInto(ReadonlyVec3D v,
Vec3D result)
ReadonlyVec3D
crossInto in interface ReadonlyVec3Dv - vector to crossresult - result vector
public final Vec3D crossSelf(Vec3D v)
v - the v
public final float distanceTo(ReadonlyVec3D v)
ReadonlyVec3D
distanceTo in interface ReadonlyVec3Dv - non-null vector
public final float distanceToSquared(ReadonlyVec3D v)
ReadonlyVec3D
distanceToSquared in interface ReadonlyVec3Dv - non-null vector
ReadonlyVec3D.magSquared()public final float dot(ReadonlyVec3D v)
ReadonlyVec3D
dot in interface ReadonlyVec3Dv - the v
public final float dot(Vec3D v)
public boolean equals(java.lang.Object obj)
equals in interface ReadonlyVec3Dequals in class java.lang.Object
public boolean equalsWithTolerance(ReadonlyVec3D v,
float tolerance)
ReadonlyVec3D
equalsWithTolerance in interface ReadonlyVec3Dv - the vtolerance - the tolerance
public final Vec3D floor()
public final Vec3D frac()
public final Vec3D getAbs()
ReadonlyVec3D
getAbs in interface ReadonlyVec3Dpublic final float getComponent(Vec3D.Axis id)
getComponent in interface ReadonlyVec3Dpublic final float getComponent(int id)
getComponent in interface ReadonlyVec3Dpublic final Vec3D getConstrained(AABB box)
ReadonlyVec3D
getConstrained in interface ReadonlyVec3Dbox - the box
public final Vec3D getFloored()
ReadonlyVec3D
getFloored in interface ReadonlyVec3Dpublic final Vec3D getFrac()
ReadonlyVec3D
getFrac in interface ReadonlyVec3Dpublic final Vec3D getInverted()
ReadonlyVec3D
getInverted in interface ReadonlyVec3Dpublic final Vec3D getLimited(float lim)
ReadonlyVec3D
getLimited in interface ReadonlyVec3Dlim - new maximum magnitude
public final Vec3D getNormalized()
ReadonlyVec3D
getNormalized in interface ReadonlyVec3Dpublic final Vec3D getNormalizedTo(float len)
ReadonlyVec3D
getNormalizedTo in interface ReadonlyVec3Dlen - new desired length
public final Vec3D getReciprocal()
ReadonlyVec3D
getReciprocal in interface ReadonlyVec3Dpublic final Vec3D getReflected(ReadonlyVec3D normal)
getReflected in interface ReadonlyVec3D
public final Vec3D getRotatedAroundAxis(ReadonlyVec3D axis,
float theta)
ReadonlyVec3D
getRotatedAroundAxis in interface ReadonlyVec3Daxis - the axistheta - the theta
public final Vec3D getRotatedX(float theta)
ReadonlyVec3D
getRotatedX in interface ReadonlyVec3Dtheta - the theta
public final Vec3D getRotatedY(float theta)
ReadonlyVec3D
getRotatedY in interface ReadonlyVec3Dtheta - the theta
public final Vec3D getRotatedZ(float theta)
ReadonlyVec3D
getRotatedZ in interface ReadonlyVec3Dtheta - the theta
public final Vec3D getSignum()
ReadonlyVec3D
getSignum in interface ReadonlyVec3Dpublic int hashCode()
hashCode in class java.lang.Objectpublic final float headingXY()
ReadonlyVec3D
headingXY in interface ReadonlyVec3Dpublic final float headingXZ()
ReadonlyVec3D
headingXZ in interface ReadonlyVec3Dpublic final float headingYZ()
ReadonlyVec3D
headingYZ in interface ReadonlyVec3Dpublic ReadonlyVec3D immutable()
public final Vec3D interpolateTo(ReadonlyVec3D v,
float f)
ReadonlyVec3D
interpolateTo in interface ReadonlyVec3Dv - target vectorf - interpolation factor (should be in the range 0..1)
public final Vec3D interpolateTo(ReadonlyVec3D v,
float f,
InterpolateStrategy s)
ReadonlyVec3DInterpolateStrategy.
interpolateTo in interface ReadonlyVec3Dv - target vectorf - interpolation factor (should be in the range 0..1)s - InterpolateStrategy instance
public final Vec3D interpolateTo(Vec3D v,
float f)
public final Vec3D interpolateTo(Vec3D v,
float f,
InterpolateStrategy s)
public final Vec3D interpolateToSelf(ReadonlyVec3D v,
float f)
v - target vectorf - interpolation factor (should be in the range 0..1)
public final Vec3D interpolateToSelf(ReadonlyVec3D v,
float f,
InterpolateStrategy s)
InterpolateStrategy.
v - target vectorf - interpolation factor (should be in the range 0..1)s - InterpolateStrategy instance
public final Vec3D invert()
public boolean isInAABB(AABB box)
ReadonlyVec3D
isInAABB in interface ReadonlyVec3Dbox - bounding box to check
public boolean isInAABB(Vec3D boxOrigin,
Vec3D boxExtent)
ReadonlyVec3D
isInAABB in interface ReadonlyVec3DboxOrigin - bounding box origin/centerboxExtent - bounding box extends (half measure)
public final boolean isMajorAxis(float tol)
ReadonlyVec3D
isMajorAxis in interface ReadonlyVec3Dpublic final boolean isZeroVector()
ReadonlyVec3DMathUtils.EPS).
isZeroVector in interface ReadonlyVec3Dpublic final Vec3D jitter(float j)
Random generator of MathUtils.
j - the j
public final Vec3D jitter(float jx,
float jy,
float jz)
Random generator of MathUtils.
jx - maximum x jitterjy - maximum y jitterjz - maximum z jitter
public final Vec3D jitter(java.util.Random rnd,
float j)
public final Vec3D jitter(java.util.Random rnd,
float jx,
float jy,
float jz)
public final Vec3D jitter(java.util.Random rnd,
Vec3D jitterVec)
public final Vec3D jitter(Vec3D jitterVec)
Random generator of
MathUtils.
jitterVec - the jitter vec
public final Vec3D limit(float lim)
lim - new maximum magnitude
public final float magnitude()
ReadonlyVec3D
magnitude in interface ReadonlyVec3Dpublic final float magSquared()
ReadonlyVec3D
magSquared in interface ReadonlyVec3Dpublic final Vec3D maxSelf(ReadonlyVec3D b)
b - the b
public final Vec3D minSelf(ReadonlyVec3D b)
b - the b
public final Vec3D modSelf(float base)
base - the base
public final Vec3D modSelf(float bx,
float by,
float bz)
bx - the bxby - the bybz - the bz
public final Vec3D normalize()
public final Vec3D normalizeTo(float len)
len - desired length
public final Vec3D reciprocal()
public final Vec3D reflect(ReadonlyVec3D normal)
public final Vec3D rotateAroundAxis(ReadonlyVec3D axis,
float theta)
axis - rotation axis vectortheta - rotation angle (in radians)
public final Vec3D rotateX(float theta)
theta - the theta
public final Vec3D rotateY(float theta)
theta - the theta
public final Vec3D rotateZ(float theta)
theta - the theta
public final Vec3D roundToAxis()
public Vec3D scale(float s)
ReadonlyVec3D
scale in interface ReadonlyVec3Ds - scale factor
public Vec3D scale(float a,
float b,
float c)
ReadonlyVec3D
scale in interface ReadonlyVec3Da - scale factor for X coordinateb - scale factor for Y coordinatec - scale factor for Z coordinate
public Vec3D scale(ReadonlyVec3D s)
ReadonlyVec3D
scale in interface ReadonlyVec3Ds - scale vector
public Vec3D scale(Vec3D s)
public Vec3D scaleSelf(float s)
s - scale factor
public Vec3D scaleSelf(float a,
float b,
float c)
a - scale factor for X coordinateb - scale factor for Y coordinatec - scale factor for Z coordinate
public Vec3D scaleSelf(Vec3D s)
s - scale vector
public Vec3D set(float x,
float y,
float z)
x - the xy - the yz - the z
public Vec3D set(ReadonlyVec3D v)
public Vec3D set(Vec3D v)
v - vector to be copied
public final Vec3D setComponent(Vec3D.Axis id,
float val)
public final Vec3D setComponent(int id,
float val)
public Vec3D setXY(Vec2D v)
v - 2D vector
public Vec3D shuffle(int iterations)
public Vec3D signum()
public final Vec3D sub(float a,
float b,
float c)
ReadonlyVec3D
sub in interface ReadonlyVec3Da - X coordinateb - Y coordinatec - Z coordinate
public final Vec3D sub(ReadonlyVec3D v)
ReadonlyVec3D
sub in interface ReadonlyVec3Dv - vector to be subtracted
public final Vec3D sub(Vec3D v)
public final Vec3D subSelf(float a,
float b,
float c)
a - X coordinateb - Y coordinatec - Z coordinate
public final Vec3D subSelf(Vec3D v)
v - vector to be subtracted
public final Vec2D to2DXY()
ReadonlyVec3D
to2DXY in interface ReadonlyVec3Dpublic final Vec2D to2DXZ()
ReadonlyVec3D
to2DXZ in interface ReadonlyVec3Dpublic final Vec2D to2DYZ()
ReadonlyVec3D
to2DYZ in interface ReadonlyVec3Dpublic float[] toArray()
toArray in interface ReadonlyVec3Dpublic float[] toArray4(float w)
public final Vec3D toCartesian()
ReadonlyVec3D
toCartesian in interface ReadonlyVec3Dpublic final Vec3D toSpherical()
ReadonlyVec3D
toSpherical in interface ReadonlyVec3Dpublic java.lang.String toString()
toString in class java.lang.Objectpublic final float x()
x in interface ReadonlyVec3Dpublic final float y()
y in interface ReadonlyVec3Dpublic final float z()
z in interface ReadonlyVec3D
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||