Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## toxi.geom
Class Vec3D

    java.lang.Object
      toxi.geom.Vec3D

All Implemented Interfaces:
  java.lang.Comparable<ReadonlyVec3D>, ReadonlyVec3D

Direct Known Subclasses:
  AABB, Cone, Plane, Ray3D, Sphere, Vertex

    public class Vec3D

extends java.lang.Object
implements java.lang.Comparable<ReadonlyVec3D>, ReadonlyVec3D

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

### X_AXIS

    public static final ReadonlyVec3D X_AXIS

  Defines positive X axis.

### Y_AXIS

    public static final ReadonlyVec3D Y_AXIS

  Defines positive Y axis.

### Z_AXIS

    public static final ReadonlyVec3D Z_AXIS

  Defines positive Z axis.

### ZERO

    public static final ReadonlyVec3D ZERO

  Defines the zero vector.

### MIN_VALUE

    public static final ReadonlyVec3D MIN_VALUE

  Defines vector with all coords set to Float.MIN_VALUE. Useful for bounding box operations.

### MAX_VALUE

    public static final ReadonlyVec3D MAX_VALUE

  Defines vector with all coords set to Float.MAX_VALUE. Useful for bounding box operations.

### x

    public float x

  X coordinate.

### y

    public float y

  Y coordinate.

### z

    public float z

  Z coordinate.

Constructor Detail

### Vec3D

    public Vec3D()

  Creates a new zero vector.

### Vec3D

    public Vec3D(float x,
                 float y,
                 float z)

  Creates a new vector with the given coordinates.

  Parameters:
    `x` - the x
    `y` - the y
    `z` - the z

### Vec3D

    public Vec3D(ReadonlyVec3D v)

  Creates a new vector with the coordinates of the given vector.

  Parameters:
    `v` - vector to be copied

Method Detail

### fromXYTheta

    public static final Vec3D fromXYTheta(float theta)

  Creates a new vector from the given angle in the XY plane. The Z component of the vector will be zero. The resulting vector for theta=0 is equal to the positive X axis.

  Parameters:
    `theta` - the theta
  Returns:
    new vector in the XY plane

### fromXZTheta

    public static final Vec3D fromXZTheta(float theta)

  Creates a new vector from the given angle in the XZ plane. The Y component of the vector will be zero. The resulting vector for theta=0 is equal to the positive X axis.

  Parameters:
    `theta` - the theta
  Returns:
    new vector in the XZ plane

### fromYZTheta

    public static final Vec3D fromYZTheta(float theta)

  Creates a new vector from the given angle in the YZ plane. The X component of the vector will be zero. The resulting vector for theta=0 is equal to the positive Y axis.

  Parameters:
    `theta` - the theta
  Returns:
    new vector in the YZ plane

### max

    public static final Vec3D max(ReadonlyVec3D a,
                                  ReadonlyVec3D b)

  Constructs a new vector consisting of the largest components of both vectors.

  Parameters:
    `b` - the b
    `a` - the a
  Returns:
    result as new vector

### min

    public static final Vec3D min(ReadonlyVec3D a,
                                  ReadonlyVec3D b)

  Constructs a new vector consisting of the smallest components of both vectors.

  Parameters:
    `b` - comparing vector
    `a` - the a
  Returns:
    result as new vector

### randomVector

    public static final Vec3D randomVector()

  Static factory method. Creates a new random unit vector using the Random implementation set as default for the `MathUtils` class.

  Returns:
    a new random normalized unit vector.

### randomVector

    public static final Vec3D randomVector(java.util.Random rnd)

  Static factory method. Creates a new random unit vector using the given Random generator instance. I recommend to have a look at the https://uncommons-maths.dev.java.net library for a good choice of reliable and high quality random number generators.

  Parameters:
    `rnd` - the rnd
  Returns:
    a new random normalized unit vector.

### abs

    public final Vec3D abs()

  Abs.

  Returns:
    the vec3 d

### add

    public final Vec3D add(float a,
                           float b,
                           float c)

  Description copied from interface: `ReadonlyVec3D`
  Adds vector {a,b,c} and returns result as new vector.

  Specified by:
    `add` in interface `ReadonlyVec3D`
  Parameters:
    `a` - X coordinate
    `b` - Y coordinate
    `c` - Z coordinate
  Returns:
    result as new vector

### add

    public Vec3D add(ReadonlyVec3D v)

  Specified by:
    `add` in interface `ReadonlyVec3D`

### add

    public final Vec3D add(Vec3D v)

  Description copied from interface: `ReadonlyVec3D`
  Add vector v and returns result as new vector.

  Specified by:
    `add` in interface `ReadonlyVec3D`
  Parameters:
    `v` - vector to add
  Returns:
    result as new vector

### addSelf

    public final ReadonlyVec3D addSelf(float a,
                                       float b,
                                       float c)

  Adds vector {a,b,c} and overrides coordinates with result.

  Parameters:
    `a` - X coordinate
    `b` - Y coordinate
    `c` - Z coordinate
  Returns:
    itself

### addSelf

    public final Vec3D addSelf(Vec3D v)

  Adds vector v and overrides coordinates with result.

  Parameters:
    `v` - vector to add
  Returns:
    itself

### angleBetween

    public final float angleBetween(ReadonlyVec3D v)

  Description copied from interface: `ReadonlyVec3D`
  Computes the angle between this vector and vector V. This function assumes both vectors are normalized, if this can't be guaranteed, use the alternative implementation `ReadonlyVec3D.angleBetween(ReadonlyVec3D, boolean)`

  Specified by:
    `angleBetween` in interface `ReadonlyVec3D`
  Parameters:
    `v` - vector
  Returns:
    angle in radians, or NaN if vectors are parallel

### angleBetween

    public final float angleBetween(ReadonlyVec3D v,
                                    boolean forceNormalize)

  Description copied from interface: `ReadonlyVec3D`
  Computes the angle between this vector and vector V.

  Specified by:
    `angleBetween` in interface `ReadonlyVec3D`
  Parameters:
    `v` - vector
    `forceNormalize` - 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)
  Returns:
    angle in radians, or NaN if vectors are parallel

### clear

    public final ReadonlyVec3D clear()

  Sets all vector components to 0.

  Returns:
    itself

### compareTo

    public int compareTo(ReadonlyVec3D v)

  Description copied from interface: `ReadonlyVec3D`
  Compares the length of the vector with another one.

  Specified by:
    `compareTo` in interface `java.lang.Comparable<ReadonlyVec3D>`
  Specified by:
    `compareTo` in interface `ReadonlyVec3D`
  Parameters:
    `v` - vector to compare with
  Returns:
    -1 if other vector is longer, 0 if both are equal or else +1

### constrain

    public final Vec3D constrain(AABB box)

  Forcefully fits the vector in the given AABB.

  Parameters:
    `box` - the box
  Returns:
    itself

### constrain

    public final Vec3D constrain(Vec3D min,
                                 Vec3D max)

  Forcefully fits the vector in the given AABB specified by the 2 given points.

  Parameters:
    `min` -
    `max` -
  Returns:
    itself

### copy

    public Vec3D copy()

  Description copied from interface: `ReadonlyVec3D`
  Copy.

  Specified by:
    `copy` in interface `ReadonlyVec3D`
  Returns:
    a new independent instance/copy of a given vector

### cross

    public final Vec3D cross(ReadonlyVec3D v)

  Description copied from interface: `ReadonlyVec3D`
  Calculates cross-product with vector v. The resulting vector is perpendicular to both the current and supplied vector.

  Specified by:
    `cross` in interface `ReadonlyVec3D`
  Parameters:
    `v` - vector to cross
  Returns:
    cross-product as new vector

### cross

    public final Vec3D cross(Vec3D v)

### crossInto

    public final Vec3D crossInto(ReadonlyVec3D v,
                                 Vec3D result)

  Description copied from interface: `ReadonlyVec3D`
  Calculates cross-product with vector v. The resulting vector is perpendicular to both the current and supplied vector and stored in the supplied result vector.

  Specified by:
    `crossInto` in interface `ReadonlyVec3D`
  Parameters:
    `v` - vector to cross
    `result` - result vector
  Returns:
    result vector

### crossSelf

    public final Vec3D crossSelf(Vec3D v)

  Calculates cross-product with vector v. The resulting vector is perpendicular to both the current and supplied vector and overrides the current.

  Parameters:
    `v` - the v
  Returns:
    itself

### distanceTo

    public final float distanceTo(ReadonlyVec3D v)

  Description copied from interface: `ReadonlyVec3D`
  Calculates distance to another vector.

  Specified by:
    `distanceTo` in interface `ReadonlyVec3D`
  Parameters:
    `v` - non-null vector
  Returns:
    distance or Float.NaN if v=null

### distanceToSquared

    public final float distanceToSquared(ReadonlyVec3D v)

  Description copied from interface: `ReadonlyVec3D`
  Calculates the squared distance to another vector.

  Specified by:
    `distanceToSquared` in interface `ReadonlyVec3D`
  Parameters:
    `v` - non-null vector
  Returns:
    distance or NaN if v=null
  See Also:
    `ReadonlyVec3D.magSquared()`

### dot

    public final float dot(ReadonlyVec3D v)

  Description copied from interface: `ReadonlyVec3D`
  Computes the scalar product (dot product) with the given vector.

  Specified by:
    `dot` in interface `ReadonlyVec3D`
  Parameters:
    `v` - the v
  Returns:
    dot product
  See Also:
    Wikipedia entry

### dot

    public final float dot(Vec3D v)

### equals

    public boolean equals(java.lang.Object obj)

  Specified by:
    `equals` in interface `ReadonlyVec3D`
  Overrides:
    `equals` in class `java.lang.Object`

### equalsWithTolerance

    public boolean equalsWithTolerance(ReadonlyVec3D v,
                                       float tolerance)

  Description copied from interface: `ReadonlyVec3D`
  Compares 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:
    `equalsWithTolerance` in interface `ReadonlyVec3D`
  Parameters:
    `v` - the v
    `tolerance` - the tolerance
  Returns:
    true, if equal

### floor

    public final Vec3D floor()

  Replaces the vector components with integer values of their current values.

  Returns:
    itself

### frac

    public final Vec3D frac()

  Replaces the vector components with the fractional part of their current values.

  Returns:
    itself

### getAbs

    public final Vec3D getAbs()

  Description copied from interface: `ReadonlyVec3D`
  Gets the abs.

  Specified by:
    `getAbs` in interface `ReadonlyVec3D`
  Returns:
    the abs

### getComponent

    public final float getComponent(Vec3D.Axis id)

  Specified by:
    `getComponent` in interface `ReadonlyVec3D`

### getComponent

    public final float getComponent(int id)

  Specified by:
    `getComponent` in interface `ReadonlyVec3D`

### getConstrained

    public final Vec3D getConstrained(AABB box)

  Description copied from interface: `ReadonlyVec3D`
  Creates a copy of the vector which forcefully fits in the given AABB.

  Specified by:
    `getConstrained` in interface `ReadonlyVec3D`
  Parameters:
    `box` - the box
  Returns:
    fitted vector

### getFloored

    public final Vec3D getFloored()

  Description copied from interface: `ReadonlyVec3D`
  Creates a new vector whose components are the integer value of their current values.

  Specified by:
    `getFloored` in interface `ReadonlyVec3D`
  Returns:
    result as new vector

### getFrac

    public final Vec3D getFrac()

  Description copied from interface: `ReadonlyVec3D`
  Creates a new vector whose components are the fractional part of their current values.

  Specified by:
    `getFrac` in interface `ReadonlyVec3D`
  Returns:
    result as new vector

### getInverted

    public final Vec3D getInverted()

  Description copied from interface: `ReadonlyVec3D`
  Scales vector uniformly by factor -1 ( v = -v ).

  Specified by:
    `getInverted` in interface `ReadonlyVec3D`
  Returns:
    result as new vector

### getLimited

    public final Vec3D getLimited(float lim)

  Description copied from interface: `ReadonlyVec3D`
  Creates a copy of the vector with its magnitude limited to the length given.

  Specified by:
    `getLimited` in interface `ReadonlyVec3D`
  Parameters:
    `lim` - new maximum magnitude
  Returns:
    result as new vector

### getNormalized

    public final Vec3D getNormalized()

  Description copied from interface: `ReadonlyVec3D`
  Produces the normalized version as a new vector.

  Specified by:
    `getNormalized` in interface `ReadonlyVec3D`
  Returns:
    new vector

### getNormalizedTo

    public final Vec3D getNormalizedTo(float len)

  Description copied from interface: `ReadonlyVec3D`
  Produces a new vector normalized to the given length.

  Specified by:
    `getNormalizedTo` in interface `ReadonlyVec3D`
  Parameters:
    `len` - new desired length
  Returns:
    new vector

### getReciprocal

    public final Vec3D getReciprocal()

  Description copied from interface: `ReadonlyVec3D`
  Returns a multiplicative inverse copy of the vector.

  Specified by:
    `getReciprocal` in interface `ReadonlyVec3D`
  Returns:
    new vector

### getReflected

    public final Vec3D getReflected(ReadonlyVec3D normal)

  Specified by:
    `getReflected` in interface `ReadonlyVec3D`

### getRotatedAroundAxis

    public final Vec3D getRotatedAroundAxis(ReadonlyVec3D axis,
                                            float theta)

  Description copied from interface: `ReadonlyVec3D`
  Gets the rotated around axis.

  Specified by:
    `getRotatedAroundAxis` in interface `ReadonlyVec3D`
  Parameters:
    `axis` - the axis
    `theta` - the theta
  Returns:
    new result vector

### getRotatedX

    public final Vec3D getRotatedX(float theta)

  Description copied from interface: `ReadonlyVec3D`
  Creates a new vector rotated by the given angle around the X axis.

  Specified by:
    `getRotatedX` in interface `ReadonlyVec3D`
  Parameters:
    `theta` - the theta
  Returns:
    rotated vector

### getRotatedY

    public final Vec3D getRotatedY(float theta)

  Description copied from interface: `ReadonlyVec3D`
  Creates a new vector rotated by the given angle around the Y axis.

  Specified by:
    `getRotatedY` in interface `ReadonlyVec3D`
  Parameters:
    `theta` - the theta
  Returns:
    rotated vector

### getRotatedZ

    public final Vec3D getRotatedZ(float theta)

  Description copied from interface: `ReadonlyVec3D`
  Creates a new vector rotated by the given angle around the Z axis.

  Specified by:
    `getRotatedZ` in interface `ReadonlyVec3D`
  Parameters:
    `theta` - the theta
  Returns:
    rotated vector

### getSignum

    public final Vec3D getSignum()

  Description copied from interface: `ReadonlyVec3D`
  Creates a new vector in which all components are replaced with the signum of their original values. In other words if a components value was negative its new value will be -1, if zero => 0, if positive => +1

  Specified by:
    `getSignum` in interface `ReadonlyVec3D`
  Returns:
    result vector

### hashCode

    public int hashCode()

  Returns a unique code for this vector object based on it's values. If two vectors are logically equivalent, they will return the same hash code value.

  Overrides:
    `hashCode` in class `java.lang.Object`
  Returns:
    the hash code value of this vector.

### headingXY

    public final float headingXY()

  Description copied from interface: `ReadonlyVec3D`
  Computes the vector's direction in the XY plane (for example for 2D points). The positive X axis equals 0 degrees.

  Specified by:
    `headingXY` in interface `ReadonlyVec3D`
  Returns:
    rotation angle

### headingXZ

    public final float headingXZ()

  Description copied from interface: `ReadonlyVec3D`
  Computes the vector's direction in the XZ plane. The positive X axis equals 0 degrees.

  Specified by:
    `headingXZ` in interface `ReadonlyVec3D`
  Returns:
    rotation angle

### headingYZ

    public final float headingYZ()

  Description copied from interface: `ReadonlyVec3D`
  Computes the vector's direction in the YZ plane. The positive Z axis equals 0 degrees.

  Specified by:
    `headingYZ` in interface `ReadonlyVec3D`
  Returns:
    rotation angle

### immutable

    public ReadonlyVec3D immutable()

### interpolateTo

    public final Vec3D interpolateTo(ReadonlyVec3D v,
                                     float f)

  Description copied from interface: `ReadonlyVec3D`
  Interpolates the vector towards the given target vector, using linear interpolation.

  Specified by:
    `interpolateTo` in interface `ReadonlyVec3D`
  Parameters:
    `v` - target vector
    `f` - interpolation factor (should be in the range 0..1)
  Returns:
    result as new vector

### interpolateTo

    public final Vec3D interpolateTo(ReadonlyVec3D v,
                                     float f,
                                     InterpolateStrategy s)

  Description copied from interface: `ReadonlyVec3D`
  Interpolates the vector towards the given target vector, using the given `InterpolateStrategy`.

  Specified by:
    `interpolateTo` in interface `ReadonlyVec3D`
  Parameters:
    `v` - target vector
    `f` - interpolation factor (should be in the range 0..1)
    `s` - InterpolateStrategy instance
  Returns:
    result as new vector

### interpolateTo

    public final Vec3D interpolateTo(Vec3D v,
                                     float f)

### interpolateTo

    public final Vec3D interpolateTo(Vec3D v,
                                     float f,
                                     InterpolateStrategy s)

### interpolateToSelf

    public final Vec3D interpolateToSelf(ReadonlyVec3D v,
                                         float f)

  Interpolates the vector towards the given target vector, using linear interpolation.

  Parameters:
    `v` - target vector
    `f` - interpolation factor (should be in the range 0..1)
  Returns:
    itself, result overrides current vector

### interpolateToSelf

    public final Vec3D interpolateToSelf(ReadonlyVec3D v,
                                         float f,
                                         InterpolateStrategy s)

  Interpolates the vector towards the given target vector, using the given `InterpolateStrategy`.

  Parameters:
    `v` - target vector
    `f` - interpolation factor (should be in the range 0..1)
    `s` - InterpolateStrategy instance
  Returns:
    itself, result overrides current vector

### invert

    public final Vec3D invert()

  Scales vector uniformly by factor -1 ( v = -v ), overrides coordinates with result.

  Returns:
    itself

### isInAABB

    public boolean isInAABB(AABB box)

  Description copied from interface: `ReadonlyVec3D`
  Checks if the point is inside the given AABB.

  Specified by:
    `isInAABB` in interface `ReadonlyVec3D`
  Parameters:
    `box` - bounding box to check
  Returns:
    true, if point is inside

### isInAABB

    public boolean isInAABB(Vec3D boxOrigin,
                            Vec3D boxExtent)

  Description copied from interface: `ReadonlyVec3D`
  Checks if the point is inside the given axis-aligned bounding box.

  Specified by:
    `isInAABB` in interface `ReadonlyVec3D`
  Parameters:
    `boxOrigin` - bounding box origin/center
    `boxExtent` - bounding box extends (half measure)
  Returns:
    true, if point is inside the box

### isMajorAxis

    public final boolean isMajorAxis(float tol)

  Description copied from interface: `ReadonlyVec3D`
  Checks if the vector is parallel with either the X or Y axis (any direction).

  Specified by:
    `isMajorAxis` in interface `ReadonlyVec3D`
  Returns:
    true, if parallel within the given tolerance

### isZeroVector

    public final boolean isZeroVector()

  Description copied from interface: `ReadonlyVec3D`
  Checks if vector has a magnitude equals or close to zero (tolerance used is `MathUtils.EPS`).

  Specified by:
    `isZeroVector` in interface `ReadonlyVec3D`
  Returns:
    true, if zero vector

### jitter

    public final Vec3D jitter(float j)

  Add random jitter to the vector in the range -j ... +j using the default `Random` generator of `MathUtils`.

  Parameters:
    `j` - the j
  Returns:
    the vec3 d

### jitter

    public final Vec3D jitter(float jx,
                              float jy,
                              float jz)

  Adds random jitter to the vector in the range -j ... +j using the default `Random` generator of `MathUtils`.

  Parameters:
    `jx` - maximum x jitter
    `jy` - maximum y jitter
    `jz` - maximum z jitter
  Returns:
    itself

### jitter

    public final Vec3D jitter(java.util.Random rnd,
                              float j)

### jitter

    public final Vec3D jitter(java.util.Random rnd,
                              float jx,
                              float jy,
                              float jz)

### jitter

    public final Vec3D jitter(java.util.Random rnd,
                              Vec3D jitterVec)

### jitter

    public final 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`.

  Parameters:
    `jitterVec` - the jitter vec
  Returns:
    itself

### limit

    public final Vec3D limit(float lim)

  Limits the vector's magnitude to the length given.

  Parameters:
    `lim` - new maximum magnitude
  Returns:
    itself

### magnitude

    public final float magnitude()

  Description copied from interface: `ReadonlyVec3D`
  Calculates the magnitude/eucledian length of the vector.

  Specified by:
    `magnitude` in interface `ReadonlyVec3D`
  Returns:
    vector length

### magSquared

    public final float magSquared()

  Description copied from interface: `ReadonlyVec3D`
  Calculates 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:
    `magSquared` in interface `ReadonlyVec3D`
  Returns:
    squared magnitude (x^2 + y^2 + z^2)

### maxSelf

    public final Vec3D maxSelf(ReadonlyVec3D b)

  Max self.

  Parameters:
    `b` - the b
  Returns:
    the vec3 d

### minSelf

    public final Vec3D minSelf(ReadonlyVec3D b)

  Min self.

  Parameters:
    `b` - the b
  Returns:
    the vec3 d

### modSelf

    public final Vec3D modSelf(float base)

  Applies a uniform modulo operation to the vector, using the same base for all components.

  Parameters:
    `base` - the base
  Returns:
    itself

### modSelf

    public final Vec3D modSelf(float bx,
                               float by,
                               float bz)

  Calculates modulo operation for each vector component separately.

  Parameters:
    `bx` - the bx
    `by` - the by
    `bz` - the bz
  Returns:
    itself

### normalize

    public final Vec3D normalize()

  Normalizes the vector so that its magnitude = 1.

  Returns:
    itself

### normalizeTo

    public final Vec3D normalizeTo(float len)

  Normalizes the vector to the given length.

  Parameters:
    `len` - desired length
  Returns:
    itself

### reciprocal

    public final Vec3D reciprocal()

  Replaces the vector components with their multiplicative inverse.

  Returns:
    itself

### reflect

    public final Vec3D reflect(ReadonlyVec3D normal)

### rotateAroundAxis

    public final Vec3D rotateAroundAxis(ReadonlyVec3D axis,
                                        float theta)

  Rotates the vector around the giving axis.

  Parameters:
    `axis` - rotation axis vector
    `theta` - rotation angle (in radians)
  Returns:
    itself

### rotateX

    public final Vec3D rotateX(float theta)

  Rotates the vector by the given angle around the X axis.

  Parameters:
    `theta` - the theta
  Returns:
    itself

### rotateY

    public final Vec3D rotateY(float theta)

  Rotates the vector by the given angle around the Y axis.

  Parameters:
    `theta` - the theta
  Returns:
    itself

### rotateZ

    public final Vec3D rotateZ(float theta)

  Rotates the vector by the given angle around the Z axis.

  Parameters:
    `theta` - the theta
  Returns:
    itself

### roundToAxis

    public final Vec3D roundToAxis()

  Rounds the vector to the closest major axis. Assumes the vector is normalized.

  Returns:
    itself

### scale

    public Vec3D scale(float s)

  Description copied from interface: `ReadonlyVec3D`
  Scales vector uniformly and returns result as new vector.

  Specified by:
    `scale` in interface `ReadonlyVec3D`
  Parameters:
    `s` - scale factor
  Returns:
    new vector

### scale

    public Vec3D scale(float a,
                       float b,
                       float c)

  Description copied from interface: `ReadonlyVec3D`
  Scales vector non-uniformly and returns result as new vector.

  Specified by:
    `scale` in interface `ReadonlyVec3D`
  Parameters:
    `a` - scale factor for X coordinate
    `b` - scale factor for Y coordinate
    `c` - scale factor for Z coordinate
  Returns:
    new vector

### scale

    public Vec3D scale(ReadonlyVec3D s)

  Description copied from interface: `ReadonlyVec3D`
  Scales vector non-uniformly by vector v and returns result as new vector.

  Specified by:
    `scale` in interface `ReadonlyVec3D`
  Parameters:
    `s` - scale vector
  Returns:
    new vector

### scale

    public Vec3D scale(Vec3D s)

### scaleSelf

    public Vec3D scaleSelf(float s)

  Scales vector uniformly and overrides coordinates with result.

  Parameters:
    `s` - scale factor
  Returns:
    itself

### scaleSelf

    public Vec3D scaleSelf(float a,
                           float b,
                           float c)

  Scales vector non-uniformly by vector {a,b,c} and overrides coordinates with result.

  Parameters:
    `a` - scale factor for X coordinate
    `b` - scale factor for Y coordinate
    `c` - scale factor for Z coordinate
  Returns:
    itself

### scaleSelf

    public Vec3D scaleSelf(Vec3D s)

  Scales vector non-uniformly by vector v and overrides coordinates with result.

  Parameters:
    `s` - scale vector
  Returns:
    itself

### set

    public Vec3D set(float x,
                     float y,
                     float z)

  Overrides coordinates with the given values.

  Parameters:
    `x` - the x
    `y` - the y
    `z` - the z
  Returns:
    itself

### set

    public Vec3D set(ReadonlyVec3D v)

### set

    public Vec3D set(Vec3D v)

  Overrides coordinates with the ones of the given vector.

  Parameters:
    `v` - vector to be copied
  Returns:
    itself

### setComponent

    public final Vec3D setComponent(Vec3D.Axis id,
                                    float val)

### setComponent

    public final Vec3D setComponent(int id,
                                    float val)

### setXY

    public Vec3D setXY(Vec2D v)

  Overrides XY coordinates with the ones of the given 2D vector.

  Parameters:
    `v` - 2D vector
  Returns:
    itself

### shuffle

    public Vec3D shuffle(int iterations)

### signum

    public Vec3D signum()

  Replaces all vector components with the signum of their original values. In other words if a components value was negative its new value will be -1, if zero => 0, if positive => +1

  Returns:
    itself

### sub

    public final Vec3D sub(float a,
                           float b,
                           float c)

  Description copied from interface: `ReadonlyVec3D`
  Subtracts vector {a,b,c} and returns result as new vector.

  Specified by:
    `sub` in interface `ReadonlyVec3D`
  Parameters:
    `a` - X coordinate
    `b` - Y coordinate
    `c` - Z coordinate
  Returns:
    result as new vector

### sub

    public final Vec3D sub(ReadonlyVec3D v)

  Description copied from interface: `ReadonlyVec3D`
  Subtracts vector v and returns result as new vector.

  Specified by:
    `sub` in interface `ReadonlyVec3D`
  Parameters:
    `v` - vector to be subtracted
  Returns:
    result as new vector

### sub

    public final Vec3D sub(Vec3D v)

### subSelf

    public final Vec3D subSelf(float a,
                               float b,
                               float c)

  Subtracts vector {a,b,c} and overrides coordinates with result.

  Parameters:
    `a` - X coordinate
    `b` - Y coordinate
    `c` - Z coordinate
  Returns:
    itself

### subSelf

    public final Vec3D subSelf(Vec3D v)

  Subtracts vector v and overrides coordinates with result.

  Parameters:
    `v` - vector to be subtracted
  Returns:
    itself

### to2DXY

    public final Vec2D to2DXY()

  Description copied from interface: `ReadonlyVec3D`
  Creates a new 2D vector of the XY components.

  Specified by:
    `to2DXY` in interface `ReadonlyVec3D`
  Returns:
    new vector

### to2DXZ

    public final Vec2D to2DXZ()

  Description copied from interface: `ReadonlyVec3D`
  Creates a new 2D vector of the XZ components.

  Specified by:
    `to2DXZ` in interface `ReadonlyVec3D`
  Returns:
    new vector

### to2DYZ

    public final Vec2D to2DYZ()

  Description copied from interface: `ReadonlyVec3D`
  Creates a new 2D vector of the YZ components.

  Specified by:
    `to2DYZ` in interface `ReadonlyVec3D`
  Returns:
    new vector

### toArray

    public float[] toArray()

  Specified by:
    `toArray` in interface `ReadonlyVec3D`

### toArray4

    public float[] toArray4(float w)

### toCartesian

    public final Vec3D toCartesian()

  Description copied from interface: `ReadonlyVec3D`
  Converts the spherical vector back into cartesian coordinates.

  Specified by:
    `toCartesian` in interface `ReadonlyVec3D`
  Returns:
    itself

### toSpherical

    public final Vec3D toSpherical()

  Description copied from interface: `ReadonlyVec3D`
  Converts the vector into spherical coordinates. After the conversion the vector components are to be interpreted as:
  - x = radius
  - y = azimuth
  - z = theta

  Specified by:
    `toSpherical` in interface `ReadonlyVec3D`
  Returns:
    itself

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`

### x

    public final float x()

  Specified by:
    `x` in interface `ReadonlyVec3D`

### y

    public final float y()

  Specified by:
    `y` in interface `ReadonlyVec3D`

### z

    public final float z()

  Specified by:
    `z` in interface `ReadonlyVec3D`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD