Class Double3

java.lang.Object
ffx.numerics.math.Double3

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

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

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

    • Double3

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

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

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

    • fma

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

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

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

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

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

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

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

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

      public double dist(Double3 b)
      Finds the Euclidean distance between two positions.
      Parameters:
      b - Second vector.
      Returns:
      Returns the distance between this Double3 and b.
    • dist2

      public double dist2(Double3 b)
      Finds the square of the Euclidean distance between two positions.
      Parameters:
      b - Second vector.
      Returns:
      Returns the squared distance between this Double3 and b.
    • dot

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

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

      public double get(int i)
      Returns the coordinate at position i.
      Parameters:
      i - The coordinate index.
      Returns:
      The coordinate.
    • length

      public double length()
      Finds the length of this Double3.
      Returns:
      Length of vector this Double3.
    • length2

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

      public void log()
      Log this Double3.
    • normalize

      public Double3 normalize()
      Normalize this Double3.
      Returns:
      Returns a new Double3.
    • normalizeI

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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