Class LXVector

java.lang.Object
heronarts.lx.transform.LXVector

public class LXVector extends Object
A mutable version of an LXPoint, which has had a transformation applied to it, and may have other transformations applied to it. For Processing applications, this mostly conforms to the PVector API.
  • Field Details

    • x

      public float x
    • y

      public float y
    • z

      public float z
    • point

      public final LXPoint point
      Helper to retrieve the point this corresponds to
    • index

      public final int index
      Index of the LXPoint this corresponds to
  • Constructor Details

    • LXVector

      public LXVector()
      Construct a mutable vector
    • LXVector

      public LXVector(LXPoint point)
      Construct a mutable vector based on an LXPoint
      Parameters:
      point - Point with index reference
    • LXVector

      public LXVector(LXVector that)
    • LXVector

      public LXVector(float x, float y, float z)
  • Method Details

    • set

      public LXVector set(float x, float y)
    • set

      public LXVector set(float x, float y, float z)
    • set

      public LXVector set(LXVector that)
    • set

      public LXVector set(LXPoint that)
    • copy

      public LXVector copy()
    • add

      public LXVector add(float x, float y)
    • add

      public LXVector add(float x, float y, float z)
    • add

      public LXVector add(LXVector that)
    • add

      public LXVector add(LXVector that, float amount)
    • sub

      public LXVector sub(float x, float y)
    • sub

      public LXVector sub(float x, float y, float z)
    • sub

      public LXVector sub(LXVector that)
    • mult

      public LXVector mult(float n)
    • mult

      public LXVector mult(LXVector that)
    • div

      public LXVector div(float n)
    • mag

      public float mag()
    • magSq

      public float magSq()
    • dist

      public float dist(LXVector that)
    • dot

      public float dot(float x, float y, float z)
    • dot

      public float dot(LXVector that)
    • cross

      public LXVector cross(LXVector that)
    • cross

      public LXVector cross(float x, float y, float z)
    • normalize

      public LXVector normalize()
    • limit

      public LXVector limit(float max)
    • setMag

      public LXVector setMag(float mag)
    • lerp

      public LXVector lerp(LXVector that, float amt)
    • isZero

      public boolean isZero()
    • rotate

      public LXVector rotate(float theta)
      Rotate in x-y plane
      Parameters:
      theta - Radians to rotate by
      Returns:
      this
    • rotate

      public LXVector rotate(float theta, float l, float m, float n)
      Rotate about an arbitrary vector. If you are going to perform this operation on many LXVectors, it is better to use the LXProjection class to avoid a lot of redundant computation.
      Parameters:
      theta - Angle to rotate by, in radians
      l - vector x-value
      m - vector y-value
      n - vector z-value
      Returns:
      this, for method chaining
    • angleBetween

      public static float angleBetween(LXVector v1, LXVector v2)
      Calculates and returns the angle (in radians) between two vectors.
      Parameters:
      v1 - the x, y, and z components of an LXVector
      v2 - the x, y, and z components of an LXVector
      Returns:
      angle between vectors in radians
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object