java.lang.Object
com.marginallyclever.convenience.helpers.MathHelper

public class MathHelper extends Object
Math methods.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final double
     
    static final double
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    equals(javax.vecmath.Vector3d a, javax.vecmath.Vector3d b, double v)
    compare two vectors
    static long
    gcd(long a, long b)
    greatest common divider
    static double
    interpolate(double a, double b, double t)
    interpolate from a to b
    static float
    interpolate(float a, float b, double t)
    interpolate from a to b
    static javax.vecmath.Point3d
    interpolate(javax.vecmath.Point3d start, javax.vecmath.Point3d end, double t)
    interpolate from start to end
    static javax.vecmath.Vector3d
    interpolate(javax.vecmath.Vector3d start, javax.vecmath.Vector3d end, double t)
    interpolate from start to end
    static long
    lcm(long a, long b)
    least common multiplier
    static double[]
    quatToEuler(javax.vecmath.Quat4d q)
    Convert quaternion 'q' to euler radian angles roll, pitch, yaw
    static javax.vecmath.Vector3d
    slerp(javax.vecmath.Vector3d a, javax.vecmath.Vector3d b, double t)
    Spherical linear interpolation between two vectors.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • MathHelper

      public MathHelper()
  • Method Details

    • gcd

      public static long gcd(long a, long b)
      greatest common divider
      Parameters:
      a -
      b -
      Returns:
      greatest common divider
    • lcm

      public static long lcm(long a, long b)
      least common multiplier
      Parameters:
      a -
      b -
      Returns:
      least common multiplier
    • interpolate

      public static float interpolate(float a, float b, double t)
      interpolate from a to b
      Parameters:
      a -
      b -
      t - [0...1]
      Returns:
      a + (b-a)*t
    • interpolate

      public static double interpolate(double a, double b, double t)
      interpolate from a to b
      Parameters:
      a -
      b -
      t - [0...1]
      Returns:
      a + (b-a)*t
    • interpolate

      public static javax.vecmath.Vector3d interpolate(javax.vecmath.Vector3d start, javax.vecmath.Vector3d end, double t)
      interpolate from start to end
      Parameters:
      start -
      end -
      t - [0...1]
      Returns:
    • interpolate

      public static javax.vecmath.Point3d interpolate(javax.vecmath.Point3d start, javax.vecmath.Point3d end, double t)
      interpolate from start to end
      Parameters:
      start -
      end -
      t - [0...1]
      Returns:
    • slerp

      public static javax.vecmath.Vector3d slerp(javax.vecmath.Vector3d a, javax.vecmath.Vector3d b, double t)
      Spherical linear interpolation between two vectors.
      Parameters:
      a - start vector
      b - end vector
      t - [0...1]
      Returns:
      interpolated vector
    • quatToEuler

      public static double[] quatToEuler(javax.vecmath.Quat4d q)
      Convert quaternion 'q' to euler radian angles roll, pitch, yaw
      Parameters:
      q -
      Returns:
    • equals

      public static boolean equals(javax.vecmath.Vector3d a, javax.vecmath.Vector3d b, double v)
      compare two vectors
      Parameters:
      a - the first vector
      b - the second vector
      v - tolerance
      Returns:
      true if the absolute difference on every axis is less than v