Package toxi.geom

Interface ReadonlyVec4D

All Known Implementing Classes:
Vec4D

public interface ReadonlyVec4D
Readonly, immutable interface wrapper for Vec3D instances. Used throughout the library for safety purposes.
  • Method Details

    • add

      Add vector v and returns result as new vector.
      Parameters:
      v - vector to add
      Returns:
      result as new vector
    • addScaled

      Vec4D addScaled(ReadonlyVec4D t, float s)
    • addXYZ

      Vec4D addXYZ(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
    • angleBetween

      float angleBetween(ReadonlyVec4D v)
      Returns the (4-space) angle in radians between this vector and the vector parameter; the return value is constrained to the range [0,PI].
      Parameters:
      v - the other vector
      Returns:
      the angle in radians in the range [0,PI]
    • compareTo

      int compareTo(ReadonlyVec4D 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

      Vec4D copy()
      Copy.
      Returns:
      a new independent instance/copy of a given vector
    • distanceTo

      float distanceTo(ReadonlyVec4D v)
      Calculates distance to another vector.
      Parameters:
      v - non-null vector
      Returns:
      distance or Float.NaN if v=null
    • distanceToSquared

      float distanceToSquared(ReadonlyVec4D v)
      Calculates the squared distance to another vector.
      Parameters:
      v - non-null vector
      Returns:
      distance or NaN if v=null
      See Also:
    • dot

      float dot(ReadonlyVec4D v)
      Computes the scalar product (dot product) with the given vector.
      Parameters:
      v - the v
      Returns:
      dot product
      See Also:
    • equals

      boolean equals(Object obj)
      Overrides:
      equals in class Object
    • equalsWithTolerance

      boolean equalsWithTolerance(ReadonlyVec4D 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

      Vec4D getAbs()
      Gets the abs.
      Returns:
      the abs
    • getInvertedXYZ

      Vec4D getInvertedXYZ()
      Scales vector uniformly by factor -1 ( v = -v ).
      Returns:
      result as new vector
    • getMapped

      Vec4D getMapped(ScaleMap map)
      Produces a new vector with all of its coordinates passed through the given ScaleMap. This version also maps the w coordinate. For mapping only XYZ use the getMappedXYZ(ScaleMap) version.
      Parameters:
      map -
      Returns:
      mapped vector
    • getMappedXYZ

      Vec4D getMappedXYZ(ScaleMap map)
      Produces a new vector with only its XYZ coordinates passed through the given ScaleMap. This version keeps the original w coordinate. For mapping all XYZW, use the getMapped(ScaleMap) version.
      Parameters:
      map -
      Returns:
      mapped vector
    • getNormalized

      Vec4D getNormalized()
      Produces the normalized version as a new vector.
      Returns:
      new vector
    • getNormalizedTo

      Vec4D getNormalizedTo(float len)
      Produces a new vector normalized to the given length.
      Parameters:
      len - new desired length
      Returns:
      new vector
    • getRotatedAroundAxis

      Vec4D getRotatedAroundAxis(ReadonlyVec3D axis, float theta)
      Gets the rotated around axis.
      Parameters:
      axis - the axis
      theta - the theta
      Returns:
      new result vector
    • getRotatedX

      Vec4D getRotatedX(float theta)
      Creates a new vector rotated by the given angle around the X axis.
      Parameters:
      theta - the theta
      Returns:
      rotated vector
    • getRotatedY

      Vec4D getRotatedY(float theta)
      Creates a new vector rotated by the given angle around the Y axis.
      Parameters:
      theta - the theta
      Returns:
      rotated vector
    • getRotatedZ

      Vec4D getRotatedZ(float theta)
      Creates a new vector rotated by the given angle around the Z axis.
      Parameters:
      theta - the theta
      Returns:
      rotated vector
    • getRoundedXYZTo

      Vec4D getRoundedXYZTo(float prec)
      Creates a new vector with its XYZ coordinates rounded to the given precision (grid alignment). The weight component remains unmodified.
      Parameters:
      prec -
      Returns:
      grid aligned vector
    • getUnweighted

      Vec4D getUnweighted()
    • getWeighted

      Vec4D getWeighted()
    • interpolateTo

      Vec4D interpolateTo(ReadonlyVec4D 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

      Vec4D interpolateTo(ReadonlyVec4D 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
    • 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

      Vec4D scale(float s)
      Scales vector uniformly and returns result as new vector.
      Parameters:
      s - scale factor
      Returns:
      new vector
    • scale

      Vec4D scale(float x, float y, float z, float w)
      Scales vector non-uniformly and returns result as new vector.
      Parameters:
      x - scale factor for X coordinate
      y - scale factor for Y coordinate
      z - scale factor for Z coordinate
      Returns:
      new vector
    • scale

      Vec4D scale(ReadonlyVec4D s)
      Scales vector non-uniformly by vector v and returns result as new vector.
      Parameters:
      s - scale vector
      Returns:
      new vector
    • sub

      Subtracts vector v and returns result as new vector.
      Parameters:
      v - vector to be subtracted
      Returns:
      result as new vector
    • subXYZ

      Vec4D subXYZ(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
    • toArray

      float[] toArray()
    • unweightInto

      Vec3D unweightInto(Vec3D out)
    • w

      float w()
    • weightInto

      Vec3D weightInto(Vec3D out)
    • x

      float x()
    • y

      float y()
    • z

      float z()