Package toxi.geom
Class Vec4D
java.lang.Object
toxi.geom.Vec4D
- All Implemented Interfaces:
Cloneable,ReadonlyVec4D
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionVec4D()Vec4D(float x, float y, float z, float w) Vec4D(ReadonlyVec3D v, float w) -
Method Summary
Modifier and TypeMethodDescriptionabs()final Vec4Dadd(ReadonlyVec4D v) Add vector v and returns result as new vector.final Vec4DaddScaled(ReadonlyVec4D t, float s) final Vec4DaddScaledSelf(ReadonlyVec4D t, float s) final Vec4Dfinal Vec4DaddXYZ(float xx, float yy, float zz) Adds vector {a,b,c} and returns result as new vector.final Vec4Dfinal Vec4DaddXYZSelf(float xx, float yy, float zz) final Vec4Dfinal floatReturns the (4-space) angle in radians between this vector and the vector parameter; the return value is constrained to the range [0,PI].clone()intCompares the length of the vector with another one.final Vec4Dcopy()Copy.final floatCalculates distance to another vector.final floatCalculates the squared distance to another vector.final floatdot(ReadonlyVec4D v) Computes the scalar product (dot product) with the given vector.booleanReturns true if the Object v is of type ReadonlyVec4D and all of the data members of v are equal to the corresponding data members in this vector.booleanReturns true if the Object v is of type Vec4D and all of the data members of v are equal to the corresponding data members in this vector.booleanequalsWithTolerance(ReadonlyVec4D v, float tolerance) Compares this vector with the one given.getAbs()Gets the abs.final Vec4DScales vector uniformly by factor -1 ( v = -v ).Produces a new vector with all of its coordinates passed through the givenScaleMap.getMappedXYZ(ScaleMap map) Produces a new vector with only its XYZ coordinates passed through the givenScaleMap.Produces the normalized version as a new vector.getNormalizedTo(float len) Produces a new vector normalized to the given length.getRotatedAroundAxis(ReadonlyVec3D axis, float theta) Gets the rotated around axis.getRotatedX(float theta) Creates a new vector rotated by the given angle around the X axis.getRotatedY(float theta) Creates a new vector rotated by the given angle around the Y axis.getRotatedZ(float theta) Creates a new vector rotated by the given angle around the Z axis.getRoundedXYZTo(float prec) Creates a new vector with its XYZ coordinates rounded to the given precision (grid alignment).inthashCode()Returns a hash code value based on the data values in this object.final Vec4DinterpolateTo(ReadonlyVec4D v, float t) Interpolates the vector towards the given target vector, using linear interpolation.final Vec4DinterpolateTo(ReadonlyVec4D v, float f, InterpolateStrategy s) Interpolates the vector towards the given target vector, using the givenInterpolateStrategy.final Vec4DinterpolateToSelf(ReadonlyVec4D v, float t) final Vec4DinterpolateToSelf(ReadonlyVec4D v, float f, InterpolateStrategy s) final Vec4Dfinal booleanChecks if vector has a magnitude equals or close to zero (tolerance used isMathUtils.EPS).final floatCalculates the magnitude/eucledian length of the vector.final floatCalculates only the squared magnitude/length of the vector.final Vec4DNormalizes the vector so that its magnitude = 1.final Vec4DnormalizeTo(float len) Normalizes the vector to the given length.final Vec4DrotateAroundAxis(ReadonlyVec3D axis, float theta) Rotates the vector around the giving axis.final Vec4DrotateX(float theta) Rotates the vector by the given angle around the X axis.final Vec4DrotateY(float theta) Rotates the vector by the given angle around the Y axis.final Vec4DrotateZ(float theta) Rotates the vector by the given angle around the Z axis.roundXYZTo(float prec) final Vec4Dscale(float s) Scales vector uniformly and returns result as new vector.final Vec4Dscale(float xx, float yy, float zz, float ww) Scales vector non-uniformly and returns result as new vector.Scales vector non-uniformly by vector v and returns result as new vector.final Vec4DscaleSelf(float s) final Vec4DscaleXYZSelf(float s) final Vec4DscaleXYZSelf(float xscale, float yscale, float zscale) set(float x, float y, float z, float w) Overrides coordinates with the given values.final Vec4Dset(ReadonlyVec4D v) setW(float w) setX(float x) final Vec4DsetY(float y) setZ(float z) final Vec4Dsub(ReadonlyVec4D v) Subtracts vector v and returns result as new vector.final Vec4Dfinal Vec4DsubXYZ(float xx, float yy, float zz) Subtracts vector {a,b,c} and returns result as new vector.final Vec4Dfinal Vec4DsubXYZSelf(float xx, float yy, float zz) final Vec4Dfinal Vec3Dto3D()float[]toArray()toString()final Vec4Dtranslate(float xx, float yy, float zz) final Vec4Dunweight()Divides each coordinate bythe weight with and sets the coordinate to the newly calculatd ones.final Vec3DunweightInto(Vec3D out) final floatw()final Vec4Dweight()Multiplies the weight with each coordinate and sets the coordinate to the newly calculatd ones.final Vec3DweightInto(Vec3D out) final floatx()final floaty()final floatz()
-
Field Details
-
x
public float xX coordinate -
y
public float yY coordinate -
z
public float zZ coordinate -
w
public float wW coordinate (weight)
-
-
Constructor Details
-
Vec4D
public Vec4D() -
Vec4D
public Vec4D(float x, float y, float z, float w) -
Vec4D
-
Vec4D
-
-
Method Details
-
abs
-
add
Description copied from interface:ReadonlyVec4DAdd vector v and returns result as new vector.- Specified by:
addin interfaceReadonlyVec4D- Parameters:
v- vector to add- Returns:
- result as new vector
-
addScaled
- Specified by:
addScaledin interfaceReadonlyVec4D
-
addScaledSelf
-
addSelf
-
addXYZ
Description copied from interface:ReadonlyVec4DAdds vector {a,b,c} and returns result as new vector.- Specified by:
addXYZin interfaceReadonlyVec4D- Parameters:
xx- X coordinateyy- Y coordinatezz- Z coordinate- Returns:
- result as new vector
-
addXYZ
-
addXYZSelf
-
addXYZSelf
-
angleBetween
Returns the (4-space) angle in radians between this vector and the vector parameter; the return value is constrained to the range [0,PI].- Specified by:
angleBetweenin interfaceReadonlyVec4D- Parameters:
v- the other vector- Returns:
- the angle in radians in the range [0,PI]
-
clone
-
compareTo
Description copied from interface:ReadonlyVec4DCompares the length of the vector with another one.- Specified by:
compareToin interfaceReadonlyVec4D- Parameters:
v- vector to compare with- Returns:
- -1 if other vector is longer, 0 if both are equal or else +1
-
copy
Description copied from interface:ReadonlyVec4DCopy.- Specified by:
copyin interfaceReadonlyVec4D- Returns:
- a new independent instance/copy of a given vector
-
distanceTo
Description copied from interface:ReadonlyVec4DCalculates distance to another vector.- Specified by:
distanceToin interfaceReadonlyVec4D- Parameters:
v- non-null vector- Returns:
- distance or Float.NaN if v=null
-
distanceToSquared
Description copied from interface:ReadonlyVec4DCalculates the squared distance to another vector.- Specified by:
distanceToSquaredin interfaceReadonlyVec4D- Parameters:
v- non-null vector- Returns:
- distance or NaN if v=null
- See Also:
-
dot
Description copied from interface:ReadonlyVec4DComputes the scalar product (dot product) with the given vector.- Specified by:
dotin interfaceReadonlyVec4D- Parameters:
v- the v- Returns:
- dot product
- See Also:
-
equals
Returns true if the Object v is of type ReadonlyVec4D and all of the data members of v are equal to the corresponding data members in this vector.- Specified by:
equalsin interfaceReadonlyVec4D- Overrides:
equalsin classObject- Parameters:
v- the Object with which the comparison is made- Returns:
- true or false
-
equals
Returns true if the Object v is of type Vec4D and all of the data members of v are equal to the corresponding data members in this vector.- Parameters:
v- the vector with which the comparison is made- Returns:
- true or false
-
equalsWithTolerance
Description copied from interface:ReadonlyVec4DCompares this vector with the one given. The vectors are deemed equal if the individual differences of all component values are within the given tolerance.- Specified by:
equalsWithTolerancein interfaceReadonlyVec4D- Parameters:
v- the vtolerance- the tolerance- Returns:
- true, if equal
-
getAbs
Description copied from interface:ReadonlyVec4DGets the abs.- Specified by:
getAbsin interfaceReadonlyVec4D- Returns:
- the abs
-
getInvertedXYZ
Description copied from interface:ReadonlyVec4DScales vector uniformly by factor -1 ( v = -v ).- Specified by:
getInvertedXYZin interfaceReadonlyVec4D- Returns:
- result as new vector
-
getMapped
Description copied from interface:ReadonlyVec4DProduces a new vector with all of its coordinates passed through the givenScaleMap. This version also maps the w coordinate. For mapping only XYZ use theReadonlyVec4D.getMappedXYZ(ScaleMap)version.- Specified by:
getMappedin interfaceReadonlyVec4D- Returns:
- mapped vector
-
getMappedXYZ
Description copied from interface:ReadonlyVec4DProduces a new vector with only its XYZ coordinates passed through the givenScaleMap. This version keeps the original w coordinate. For mapping all XYZW, use theReadonlyVec4D.getMapped(ScaleMap)version.- Specified by:
getMappedXYZin interfaceReadonlyVec4D- Returns:
- mapped vector
-
getNormalized
Description copied from interface:ReadonlyVec4DProduces the normalized version as a new vector.- Specified by:
getNormalizedin interfaceReadonlyVec4D- Returns:
- new vector
-
getNormalizedTo
Description copied from interface:ReadonlyVec4DProduces a new vector normalized to the given length.- Specified by:
getNormalizedToin interfaceReadonlyVec4D- Parameters:
len- new desired length- Returns:
- new vector
-
getRotatedAroundAxis
Description copied from interface:ReadonlyVec4DGets the rotated around axis.- Specified by:
getRotatedAroundAxisin interfaceReadonlyVec4D- Parameters:
axis- the axistheta- the theta- Returns:
- new result vector
-
getRotatedX
Description copied from interface:ReadonlyVec4DCreates a new vector rotated by the given angle around the X axis.- Specified by:
getRotatedXin interfaceReadonlyVec4D- Parameters:
theta- the theta- Returns:
- rotated vector
-
getRotatedY
Description copied from interface:ReadonlyVec4DCreates a new vector rotated by the given angle around the Y axis.- Specified by:
getRotatedYin interfaceReadonlyVec4D- Parameters:
theta- the theta- Returns:
- rotated vector
-
getRotatedZ
Description copied from interface:ReadonlyVec4DCreates a new vector rotated by the given angle around the Z axis.- Specified by:
getRotatedZin interfaceReadonlyVec4D- Parameters:
theta- the theta- Returns:
- rotated vector
-
getRoundedXYZTo
Description copied from interface:ReadonlyVec4DCreates a new vector with its XYZ coordinates rounded to the given precision (grid alignment). The weight component remains unmodified.- Specified by:
getRoundedXYZToin interfaceReadonlyVec4D- Returns:
- grid aligned vector
-
getUnweighted
- Specified by:
getUnweightedin interfaceReadonlyVec4D
-
getWeighted
- Specified by:
getWeightedin interfaceReadonlyVec4D
-
hashCode
public int hashCode()Returns a hash code value based on the data values in this object. Two different Vec4D objects with identical data values (i.e., Vec4D.equals returns true) will return the same hash code value. Two objects with different data members may return the same hash value, although this is not likely. -
interpolateTo
Description copied from interface:ReadonlyVec4DInterpolates the vector towards the given target vector, using linear interpolation.- Specified by:
interpolateToin interfaceReadonlyVec4D- Parameters:
v- target vectort- interpolation factor (should be in the range 0..1)- Returns:
- result as new vector
-
interpolateTo
Description copied from interface:ReadonlyVec4DInterpolates the vector towards the given target vector, using the givenInterpolateStrategy.- Specified by:
interpolateToin interfaceReadonlyVec4D- Parameters:
v- target vectorf- interpolation factor (should be in the range 0..1)s- InterpolateStrategy instance- Returns:
- result as new vector
-
interpolateToSelf
-
interpolateToSelf
-
invertXYZ
-
isZeroVector
public final boolean isZeroVector()Description copied from interface:ReadonlyVec4DChecks if vector has a magnitude equals or close to zero (tolerance used isMathUtils.EPS).- Specified by:
isZeroVectorin interfaceReadonlyVec4D- Returns:
- true, if zero vector
-
magnitude
public final float magnitude()Description copied from interface:ReadonlyVec4DCalculates the magnitude/eucledian length of the vector.- Specified by:
magnitudein interfaceReadonlyVec4D- Returns:
- vector length
-
magSquared
public final float magSquared()Description copied from interface:ReadonlyVec4DCalculates only the squared magnitude/length of the vector. Useful for inverse square law applications and/or for speed reasons or if the real eucledian distance is not required (e.g. sorting).- Specified by:
magSquaredin interfaceReadonlyVec4D- Returns:
- squared magnitude (x^2 + y^2 + z^2)
-
normalize
Normalizes the vector so that its magnitude = 1.- Returns:
- itself
-
normalizeTo
Normalizes the vector to the given length.- Parameters:
len- desired length- Returns:
- itself
-
rotateAroundAxis
Rotates the vector around the giving axis.- Parameters:
axis- rotation axis vectortheta- rotation angle (in radians)- Returns:
- itself
-
rotateX
Rotates the vector by the given angle around the X axis.- Parameters:
theta- the theta- Returns:
- itself
-
rotateY
Rotates the vector by the given angle around the Y axis.- Parameters:
theta- the theta- Returns:
- itself
-
rotateZ
Rotates the vector by the given angle around the Z axis.- Parameters:
theta- the theta- Returns:
- itself
-
roundXYZTo
-
scale
Description copied from interface:ReadonlyVec4DScales vector uniformly and returns result as new vector.- Specified by:
scalein interfaceReadonlyVec4D- Parameters:
s- scale factor- Returns:
- new vector
-
scale
Description copied from interface:ReadonlyVec4DScales vector non-uniformly and returns result as new vector.- Specified by:
scalein interfaceReadonlyVec4D- Parameters:
xx- scale factor for X coordinateyy- scale factor for Y coordinatezz- scale factor for Z coordinate- Returns:
- new vector
-
scale
Description copied from interface:ReadonlyVec4DScales vector non-uniformly by vector v and returns result as new vector.- Specified by:
scalein interfaceReadonlyVec4D- Parameters:
s- scale vector- Returns:
- new vector
-
scaleSelf
-
scaleSelf
-
scaleXYZSelf
-
scaleXYZSelf
-
set
Overrides coordinates with the given values.- Parameters:
x- the xy- the yz- the zw- the w- Returns:
- itself
-
set
-
setW
-
setX
-
setXYZ
-
setY
-
setZ
-
sub
Description copied from interface:ReadonlyVec4DSubtracts vector v and returns result as new vector.- Specified by:
subin interfaceReadonlyVec4D- Parameters:
v- vector to be subtracted- Returns:
- result as new vector
-
subSelf
-
subXYZ
Description copied from interface:ReadonlyVec4DSubtracts vector {a,b,c} and returns result as new vector.- Specified by:
subXYZin interfaceReadonlyVec4D- Parameters:
xx- X coordinateyy- Y coordinatezz- Z coordinate- Returns:
- result as new vector
-
subXYZ
-
subXYZSelf
-
subXYZSelf
-
to3D
-
toArray
public float[] toArray()- Specified by:
toArrayin interfaceReadonlyVec4D
-
toString
-
translate
-
unweight
Divides each coordinate bythe weight with and sets the coordinate to the newly calculatd ones. -
unweightInto
- Specified by:
unweightIntoin interfaceReadonlyVec4D
-
w
public final float w()- Specified by:
win interfaceReadonlyVec4D- Returns:
- the w
-
weight
Multiplies the weight with each coordinate and sets the coordinate to the newly calculatd ones.- Returns:
- itself
-
weightInto
- Specified by:
weightIntoin interfaceReadonlyVec4D
-
x
public final float x()- Specified by:
xin interfaceReadonlyVec4D- Returns:
- the x
-
y
public final float y()- Specified by:
yin interfaceReadonlyVec4D- Returns:
- the y
-
z
public final float z()- Specified by:
zin interfaceReadonlyVec4D- Returns:
- the z
-