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
Interface ReadonlyVec3D

All Known Implementing Classes:
  AABB, Cone, Plane, PointOctree, Ray3D, Sphere, Vec3D, Vertex, WEVertex

    public interface ReadonlyVec3D

Readonly, immutable interface wrapper for Vec3D instances. Used throughout the library for safety purposes.

Method Summary
`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.
`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.
`int` | `compareTo(ReadonlyVec3D v)` Compares the length of the vector with another one.
`Vec3D` | `copy()` Copy.
`Vec3D` | `cross(ReadonlyVec3D v)` Calculates cross-product with vector v.
`Vec3D` | `crossInto(ReadonlyVec3D v, Vec3D result)` 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.
`boolean` | `equals(java.lang.Object obj)`
`boolean` | `equalsWithTolerance(ReadonlyVec3D v, float tolerance)` Compares this vector with the one given.
`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.
`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.
`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`.
`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 tolerance)` 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`).
`float` | `magnitude()` Calculates the magnitude/eucledian length of the vector.
`float` | `magSquared()` Calculates only the squared magnitude/length of the vector.
`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` | `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.
`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()`
`Vec3D` | `toCartesian()` Converts the spherical vector back into cartesian coordinates.
`Vec3D` | `toSpherical()` Converts the vector into spherical coordinates.
`float` | `x()`
`float` | `y()`
`float` | `z()`

Method Detail

### add

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

  Adds vector {a,b,c} and returns result as new vector.

  Parameters:
    `a` - X coordinate
    `b` - Y coordinate
    `c` - Z coordinate
  Returns:
    result as new vector

### add

    Vec3D add(ReadonlyVec3D v)

### add

    Vec3D add(Vec3D v)

  Add vector v and returns result as new vector.

  Parameters:
    `v` - vector to add
  Returns:
    result as new vector

### angleBetween

    float angleBetween(ReadonlyVec3D v)

  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 `angleBetween(ReadonlyVec3D, boolean)`

  Parameters:
    `v` - vector
  Returns:
    angle in radians, or NaN if vectors are parallel

### angleBetween

    float angleBetween(ReadonlyVec3D v,
                       boolean forceNormalize)

  Computes the angle between this vector and vector V.

  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

### compareTo

    int compareTo(ReadonlyVec3D v)

  Compares the length of the vector with another one.

  Parameters:
    `v` - vector to compare with
  Returns:
    -1 if other vector is longer, 0 if both are equal or else +1

### copy

    Vec3D copy()

  Copy.

  Returns:
    a new independent instance/copy of a given vector

### cross

    Vec3D cross(ReadonlyVec3D v)

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

  Parameters:
    `v` - vector to cross
  Returns:
    cross-product as new vector

### crossInto

    Vec3D crossInto(ReadonlyVec3D v,
                    Vec3D result)

  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.

  Parameters:
    `v` - vector to cross
    `result` - result vector
  Returns:
    result vector

### distanceTo

    float distanceTo(ReadonlyVec3D v)

  Calculates distance to another vector.

  Parameters:
    `v` - non-null vector
  Returns:
    distance or Float.NaN if v=null

### distanceToSquared

    float distanceToSquared(ReadonlyVec3D v)

  Calculates the squared distance to another vector.

  Parameters:
    `v` - non-null vector
  Returns:
    distance or NaN if v=null
  See Also:
    `magSquared()`

### dot

    float dot(ReadonlyVec3D v)

  Computes the scalar product (dot product) with the given vector.

  Parameters:
    `v` - the v
  Returns:
    dot product
  See Also:
    Wikipedia entry

### equals

    boolean equals(java.lang.Object obj)

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

### equalsWithTolerance

    boolean equalsWithTolerance(ReadonlyVec3D v,
                                float tolerance)

  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.

  Parameters:
    `v` - the v
    `tolerance` - the tolerance
  Returns:
    true, if equal

### getAbs

    Vec3D getAbs()

  Gets the abs.

  Returns:
    the abs

### getComponent

    float getComponent(Vec3D.Axis id)

### getComponent

    float getComponent(int id)

### getConstrained

    Vec3D getConstrained(AABB box)

  Creates a copy of the vector which forcefully fits in the given AABB.

  Parameters:
    `box` - the box
  Returns:
    fitted vector

### getFloored

    Vec3D getFloored()

  Creates a new vector whose components are the integer value of their current values.

  Returns:
    result as new vector

### getFrac

    Vec3D getFrac()

  Creates a new vector whose components are the fractional part of their current values.

  Returns:
    result as new vector

### getInverted

    Vec3D getInverted()

  Scales vector uniformly by factor -1 ( v = -v ).

  Returns:
    result as new vector

### getLimited

    Vec3D getLimited(float lim)

  Creates a copy of the vector with its magnitude limited to the length given.

  Parameters:
    `lim` - new maximum magnitude
  Returns:
    result as new vector

### getNormalized

    Vec3D getNormalized()

  Produces the normalized version as a new vector.

  Returns:
    new vector

### getNormalizedTo

    Vec3D getNormalizedTo(float len)

  Produces a new vector normalized to the given length.

  Parameters:
    `len` - new desired length
  Returns:
    new vector

### getReciprocal

    Vec3D getReciprocal()

  Returns a multiplicative inverse copy of the vector.

  Returns:
    new vector

### getReflected

    Vec3D getReflected(ReadonlyVec3D normal)

### getRotatedAroundAxis

    Vec3D getRotatedAroundAxis(ReadonlyVec3D axis,
                               float theta)

  Gets the rotated around axis.

  Parameters:
    `axis` - the axis
    `theta` - the theta
  Returns:
    new result vector

### getRotatedX

    Vec3D getRotatedX(float theta)

  Creates a new vector rotated by the given angle around the X axis.

  Parameters:
    `theta` - the theta
  Returns:
    rotated vector

### getRotatedY

    Vec3D getRotatedY(float theta)

  Creates a new vector rotated by the given angle around the Y axis.

  Parameters:
    `theta` - the theta
  Returns:
    rotated vector

### getRotatedZ

    Vec3D getRotatedZ(float theta)

  Creates a new vector rotated by the given angle around the Z axis.

  Parameters:
    `theta` - the theta
  Returns:
    rotated vector

### getSignum

    Vec3D getSignum()

  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

  Returns:
    result vector

### headingXY

    float headingXY()

  Computes the vector's direction in the XY plane (for example for 2D points). The positive X axis equals 0 degrees.

  Returns:
    rotation angle

### headingXZ

    float headingXZ()

  Computes the vector's direction in the XZ plane. The positive X axis equals 0 degrees.

  Returns:
    rotation angle

### headingYZ

    float headingYZ()

  Computes the vector's direction in the YZ plane. The positive Z axis equals 0 degrees.

  Returns:
    rotation angle

### interpolateTo

    Vec3D interpolateTo(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:
    result as new vector

### interpolateTo

    Vec3D interpolateTo(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:
    result as new vector

### isInAABB

    boolean isInAABB(AABB box)

  Checks if the point is inside the given AABB.

  Parameters:
    `box` - bounding box to check
  Returns:
    true, if point is inside

### isInAABB

    boolean isInAABB(Vec3D boxOrigin,
                     Vec3D boxExtent)

  Checks if the point is inside the given axis-aligned bounding box.

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

### isMajorAxis

    boolean isMajorAxis(float tolerance)

  Checks if the vector is parallel with either the X or Y axis (any direction).

  Parameters:
    `tolerance` -
  Returns:
    true, if parallel within the given tolerance

### isZeroVector

    boolean isZeroVector()

  Checks if vector has a magnitude equals or close to zero (tolerance used is `MathUtils.EPS`).

  Returns:
    true, if zero vector

### magnitude

    float magnitude()

  Calculates the magnitude/eucledian length of the vector.

  Returns:
    vector length

### magSquared

    float magSquared()

  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).

  Returns:
    squared magnitude (x^2 + y^2 + z^2)

### scale

    Vec3D scale(float s)

  Scales vector uniformly and returns result as new vector.

  Parameters:
    `s` - scale factor
  Returns:
    new vector

### scale

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

  Scales vector non-uniformly and returns result as new vector.

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

### scale

    Vec3D scale(ReadonlyVec3D s)

  Scales vector non-uniformly by vector v and returns result as new vector.

  Parameters:
    `s` - scale vector
  Returns:
    new vector

### sub

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

  Subtracts vector {a,b,c} and returns result as new vector.

  Parameters:
    `a` - X coordinate
    `b` - Y coordinate
    `c` - Z coordinate
  Returns:
    result as new vector

### sub

    Vec3D sub(ReadonlyVec3D v)

  Subtracts vector v and returns result as new vector.

  Parameters:
    `v` - vector to be subtracted
  Returns:
    result as new vector

### to2DXY

    Vec2D to2DXY()

  Creates a new 2D vector of the XY components.

  Returns:
    new vector

### to2DXZ

    Vec2D to2DXZ()

  Creates a new 2D vector of the XZ components.

  Returns:
    new vector

### to2DYZ

    Vec2D to2DYZ()

  Creates a new 2D vector of the YZ components.

  Returns:
    new vector

### toArray

    float[] toArray()

### toCartesian

    Vec3D toCartesian()

  Converts the spherical vector back into cartesian coordinates.

  Returns:
    itself

### toSpherical

    Vec3D toSpherical()

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

  Returns:
    itself

### x

    float x()

### y

    float y()

### z

    float z()

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