Class Float3

java.lang.Object
ffx.numerics.math.Float3

public class Float3 extends Object
Convenience class for working with 3D float vectors.
Since:
1.0
Author:
Michael J. Schnieders
  • Constructor Summary

    Constructors
    Constructor
    Description
    Construct a Float3 at (0.0, 0.0, 0.0).
    Float3(float[] a)
    Construct a Float3 at a.
    Float3(float x, float y, float z)
    Construct a Float3 at (x, y, z).
  • Method Summary

    Modifier and Type
    Method
    Description
    Finds the sum of this Float3 with b.
    Finds the sum of this Float3 with b in place.
    float
    Angle of this Float3 with b.
    Returns a new copy of this Float3.
    float
    Finds the distance between two vectors.
    float
    Finds the squared distance between two vectors
    float
    Finds the dot product between two vectors.
    fma(float b, Float3 c)
    Compute a * b + c and return the result in a new Float3.
    fmaI(float b, Float3 c)
    Compute a * b + c and return the result in a new Float3.
    float[]
    get()
    Returns a reference to the internal float array that stores this Float3.
    float
    get(int i)
    Returns the coordinate at position i.
    float
    Finds the length of this Float3.
    float
    Finds the length of this Float3 squared.
    void
    log()
    Log this Float3.
    Normalize this Float3.
    Normalize this Float3 in place.
    scale(float d)
    Scales a Float3.
    scaleI(float d)
    Scales a Float3 in place.
    set(float[] b)
    Set the value of this Float3.
    set(float x, float y, float z)
    Set the value of this Float3.
    Set the value of this Float3.
    Square roots values in Float3.
    Square roots values in Float3 in place.
    Squares values in Float3.
    Squares values in Float3 in place.
    Finds the difference between two vectors.
    Finds the difference between two vectors.
    Describe this Float3 in a String.
    float
    x()
    Get the value x.
    X(Float3 b)
    Cross product of this Float3 with b.
    In-place Cross product of this Float3 with b.
    float
    y()
    Get the value of y.
    float
    z()
    Get the value of z.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Float3

      public Float3()
      Construct a Float3 at (0.0, 0.0, 0.0).
    • Float3

      public Float3(float x, float y, float z)
      Construct a Float3 at (x, y, z).
      Parameters:
      x - X value.
      y - Y value.
      z - Z value.
    • Float3

      public Float3(float[] a)
      Construct a Float3 at a.
      Parameters:
      a - Float3 to initialize from (the data is copied).
  • Method Details

    • fma

      public Float3 fma(float b, Float3 c)
      Compute a * b + c and return the result in a new Float3.
      Parameters:
      b - Scalar.
      c - Float3.
      Returns:
      Returns the FMA of a * b + c in a new Float3.
    • fmaI

      public Float3 fmaI(float b, Float3 c)
      Compute a * b + c and return the result in a new Float3.
      Parameters:
      b - Scalar.
      c - Float3.
      Returns:
      Returns the FMA of a * b + c in a new Float3.
    • X

      public Float3 X(Float3 b)
      Cross product of this Float3 with b.
      Parameters:
      b - Vector b.
      Returns:
      Returns the cross product in a new Float3.
    • XI

      public Float3 XI(Float3 b)
      In-place Cross product of this Float3 with b.
      Parameters:
      b - Vector b.
      Returns:
      Returns the cross product in this Float3.
    • add

      public Float3 add(Float3 b)
      Finds the sum of this Float3 with b.
      Parameters:
      b - Second Float3.
      Returns:
      Returns the sum in a new Float3.
    • addI

      public Float3 addI(Float3 b)
      Finds the sum of this Float3 with b in place.
      Parameters:
      b - Second Float3.
      Returns:
      Returns the sum in this Float3.
    • angle

      public float angle(Float3 b)
      Angle of this Float3 with b.
      Parameters:
      b - Vector b.
      Returns:
      Returns the angle.
    • copy

      public Float3 copy()
      Returns a new copy of this Float3.
      Returns:
      Returns a copy of this Float3.
    • dist

      public float dist(Float3 b)
      Finds the distance between two vectors.
      Parameters:
      b - Second vector.
      Returns:
      Returns the distance between this Float3 and b.
    • dist2

      public float dist2(Float3 b)
      Finds the squared distance between two vectors
      Parameters:
      b - Second vector.
      Returns:
      Returns the squared distance between this Float3 and b.
    • dot

      public float dot(Float3 b)
      Finds the dot product between two vectors.
      Parameters:
      b - Second vector.
      Returns:
      Returns the dot product of this Float3 and b.
    • get

      public float[] get()
      Returns a reference to the internal float array that stores this Float3.
      Returns:
      A reference to the internal float array.
    • get

      public float get(int i)
      Returns the coordinate at position i.
      Returns:
      The coordinate.
    • length

      public float length()
      Finds the length of this Float3.
      Returns:
      Length of vector this Float3.
    • length2

      public float length2()
      Finds the length of this Float3 squared.
      Returns:
      Length of vector this Float3 squared.
    • log

      public void log()
      Log this Float3.
    • normalize

      public Float3 normalize()
      Normalize this Float3.
      Returns:
      Returns the normalized vector in a new Float3.
    • normalizeI

      public Float3 normalizeI()
      Normalize this Float3 in place.
      Returns:
      Returns a reference to this Float3 normalized.
    • scale

      public Float3 scale(float d)
      Scales a Float3.
      Parameters:
      d - A scalar value.
      Returns:
      Returns a new scaled Float3.
    • scaleI

      public Float3 scaleI(float d)
      Scales a Float3 in place.
      Parameters:
      d - A scalar value.
      Returns:
      Returns a reference to this Float3 scaled.
    • square

      public Float3 square()
      Squares values in Float3.
      Returns:
      Returns a reference to this Float3 squared.
    • squareI

      public Float3 squareI()
      Squares values in Float3 in place.
      Returns:
      Returns a reference to this Float3 squared.
    • sqrt

      public Float3 sqrt()
      Square roots values in Float3.
      Returns:
      Returns a reference to this Float3 square rooted.
    • sqrtI

      public Float3 sqrtI()
      Square roots values in Float3 in place.
      Returns:
      Returns a reference to this Float3 square rooted.
    • set

      public Float3 set(float x, float y, float z)
      Set the value of this Float3.
      Parameters:
      x - X-value.
      y - Y-value.
      z - Z-value.
      Returns:
      A reference to this Float3.
    • set

      public Float3 set(float[] b)
      Set the value of this Float3.
      Parameters:
      b - Double array that is copied.
      Returns:
      A reference to this Float3.
    • set

      public Float3 set(Float3 b)
      Set the value of this Float3.
      Parameters:
      b - Float3 that is copied.
      Returns:
      A reference to this Float3.
    • sub

      public Float3 sub(Float3 b)
      Finds the difference between two vectors.
      Parameters:
      b - Second vector
      Returns:
      Returns the difference in a new Float3.
    • subI

      public Float3 subI(Float3 b)
      Finds the difference between two vectors.
      Parameters:
      b - Second vector
      Returns:
      Returns the difference in this Float3.
    • toString

      public String toString()
      Describe this Float3 in a String.
      Overrides:
      toString in class Object
      Returns:
      Returns a String description.
    • x

      public float x()
      Get the value x.
      Returns:
      Returns x.
    • y

      public float y()
      Get the value of y.
      Returns:
      Returns y.
    • z

      public float z()
      Get the value of z.
      Returns:
      Returns z.