signature:
public class GenericMath { /** * Interpolates a quaternion between two others using spherical linear interpolation .
 * @ param a The first quaternion
 * @ param b The second quaternion
 * @ param percent The percent for the interpolation , between 0 and 1 inclusively
 * @ return The interpolated quaternion */
public static Quaternionf slerp ( Quaternionf a , Quaternionf b , float percent ) { } }

implementation: final float inverted ; float cosineTheta = a . dot ( b ) ; if ( cosineTheta < 0 ) { cosineTheta = - cosineTheta ; inverted = - 1 ; } else { inverted = 1 ; } if ( 1 - cosineTheta < GenericMath . FLT_EPSILON ) { return a . mul ( 1 - percent ) . add ( b . mul ( percent * inverted ) ) ; } final float theta = ( float ) TrigMath . acos ( cosineTheta ) ; final float sineTheta = TrigMath . sin ( theta ) ; final float coefficient1 = TrigMath . sin ( ( 1 - percent ) * theta ) / sineTheta ; final float coefficient2 = TrigMath . sin ( percent * theta ) / sineTheta * inverted ; return a . mul ( coefficient1 ) . add ( b . mul ( coefficient2 ) ) ;


signature:
public class GenericMath { /** * Interpolates a quaternion between two others using linear interpolation .
 * @ param a The first quaternion
 * @ param b The second quaternion
 * @ param percent The percent for the interpolation , between 0 and 1 inclusively
 * @ return The interpolated quaternion */
public static Quaternionf lerp ( Quaternionf a , Quaternionf b , float percent ) { } }

implementation: return a . mul ( 1 - percent ) . add ( b . mul ( percent ) ) ;


signature:
public class GenericMath { /** * Interpolates a quaternion between two others using linear interpolation .
 * @ param a The first quaternion
 * @ param b The second quaternion
 * @ param percent The percent for the interpolation , between 0 and 1 inclusively
 * @ return The interpolated quaternion */
public static Quaterniond lerp ( Quaterniond a , Quaterniond b , double percent ) { } }


signature:
public class GenericMath { /** * Calculates the value at x , y using bilinear interpolation
 * @ param x the X coord of the value to interpolate
 * @ param y the Y coord of the value to interpolate
 * @ param q00 the first known value ( x1 , y1)
 * @ param q01 the second known value ( x1 , y2)
 * @ param q10 the third known value ( x2 , y1)
 * @ param q11 the fourth known value ( x2 , y2)
 * @ param x1 the X coord of q00 and q01
 * @ param x2 the X coord of q10 and q11
 * @ param y1 the Y coord of q00 and q10
 * @ param y2 the Y coord of q01 and q11
 * @ return the interpolated value */
public static double biLerp ( double x , double y , double q00 , double q01 , double q10 , double q11 , double x1 , double x2 , double y1 , double y2 ) { } }

implementation: double q0 = lerp ( x , x1 , x2 , q00 , q10 ) ; double q1 = lerp ( x , x1 , x2 , q01 , q11 ) ; return lerp ( y , y1 , y2 , q0 , q1 ) ;


signature:
public class GenericMath { /** * Calculates the value at x , y , z using trilinear interpolation
 * @ param x the X coord of the value to interpolate
 * @ param y the Y coord of the value to interpolate
 * @ param z the Z coord of the value to interpolate
 * @ param q000 the first known value ( x1 , y1 , z1)
 * @ param q001 the second known value ( x1 , y2 , z1)
 * @ param q010 the third known value ( x1 , y1 , z2)
 * @ param q011 the fourth known value ( x1 , y2 , z2)
 * @ param q100 the fifth known value ( x2 , y1 , z1)
 * @ param q101 the sixth known value ( x2 , y2 , z1)
 * @ param q110 the seventh known value ( x2 , y1 , z2)
 * @ param q111 the eighth known value ( x2 , y2 , z2)
 * @ param x1 the X coord of q000 , q001 , q010 and q011
 * @ param x2 the X coord of q100 , q101 , q110 and q111
 * @ param y1 the Y coord of q000 , q010 , q100 and q110
 * @ param y2 the Y coord of q001 , q011 , q101 and q111
 * @ param z1 the Z coord of q000 , q001 , q100 and q101
 * @ param z2 the Z coord of q010 , q011 , q110 and q111
 * @ return the interpolated value */
public static double triLerp ( double x , double y , double z , double q000 , double q001 , double q010 , double q011 , double q100 , double q101 , double q110 , double q111 , double x1 , double x2 , double y1 , double y2 , double z1 , double z2 ) { } }


signature:
public class GenericMath { /** * Blends two colors into one .
 * @ param a The first color
 * @ param b The second color
 * @ return The blended color */
public static Color blend ( Color a , Color b ) { } }

implementation: return lerp ( a , b , a . getAlpha ( ) / 255f ) ;


signature:
public class GenericMath { /** * Clamps the value between the low and high boundaries
 * @ param value The value to clamp
 * @ param low The low bound of the clamp
 * @ param high The high bound of the clamp
 * @ return the clamped value */
public static double clamp ( double value , double low , double high ) { } }

implementation: if ( value < low ) { return low ; } if ( value > high ) { return high ; } return value ;


signature:
public class GenericMath { /** * Returns a fast estimate of the inverse square root of the value
 * @ param a The value
 * @ return The estimate of the inverse square root */
public static double inverseSqrt ( double a ) { } }

implementation: final double halfA = 0.5d * a ; a = Double . longBitsToDouble ( 0x5FE6EB50C7B537AAl - ( Double . doubleToRawLongBits ( a ) >> 1 ) ) ; return a * ( 1.5d - halfA * a * a ) ;


signature:
public class GenericMath { /** * Rounds an integer up to the next power of 2.
 * @ param a The integer to round
 * @ return the lowest power of 2 greater or equal to ' a ' */
public static int roundUpPow2 ( int a ) { } }

implementation: if ( a <= 0 ) { return 1 ; } else if ( a > 0x40000000 ) { throw new IllegalArgumentException ( "Rounding " + a + " to the next highest power of two would exceed the int range" ) ; } else { a -- ; a |= a >> 1 ; a |= a >> 2 ; a |= a >> 4 ; a |= a >> 8 ; a |= a >> 16 ; a ++ ; return a ; }


signature:
public class GenericMath { /** * Rounds an integer up to the next power of 2.
 * @ param a The long to round
 * @ return the lowest power of 2 greater or equal to ' a ' */
public static long roundUpPow2 ( long a ) { } }

implementation: if ( a <= 0 ) { return 1 ; } else if ( a > 0x4000000000000000L ) { throw new IllegalArgumentException ( "Rounding " + a + " to the next highest power of two would exceed the int range" ) ; } else { a -- ; a |= a >> 1 ; a |= a >> 2 ; a |= a >> 4 ; a |= a >> 8 ; a |= a >> 16 ; a |= a >> 32 ; a ++ ; return a ; }


signature:
public class GenericMath { /** * Casts a value to a float . May return null .
 * @ param o The object to attempt to cast
 * @ return The object as a float */
public static Float castFloat ( Object o ) { } }

implementation: if ( o == null ) { return null ; } if ( o instanceof Number ) { return ( ( Number ) o ) . floatValue ( ) ; } try { return Float . valueOf ( o . toString ( ) ) ; } catch ( NumberFormatException e ) { return null ; }


signature:
public class GenericMath { /** * Casts a value to a byte . May return null .
 * @ param o The object to attempt to cast
 * @ return The object as a byte */
public static Byte castByte ( Object o ) { } }

implementation: if ( o == null ) { return null ; } if ( o instanceof Number ) { return ( ( Number ) o ) . byteValue ( ) ; } try { return Byte . valueOf ( o . toString ( ) ) ; } catch ( NumberFormatException e ) { return null ; }


signature:
public class GenericMath { /** * Casts a value to a short . May return null .
 * @ param o The object to attempt to cast
 * @ return The object as a short */
public static Short castShort ( Object o ) { } }

implementation: if ( o == null ) { return null ; } if ( o instanceof Number ) { return ( ( Number ) o ) . shortValue ( ) ; } try { return Short . valueOf ( o . toString ( ) ) ; } catch ( NumberFormatException e ) { return null ; }


signature:
public class GenericMath { /** * Casts a value to an integer . May return null .
 * @ param o The object to attempt to cast
 * @ return The object as an int */
public static Integer castInt ( Object o ) { } }

implementation: if ( o == null ) { return null ; } if ( o instanceof Number ) { return ( ( Number ) o ) . intValue ( ) ; } try { return Integer . valueOf ( o . toString ( ) ) ; } catch ( NumberFormatException e ) { return null ; }


signature:
public class GenericMath { /** * Casts a value to a double . May return null .
 * @ param o The object to attempt to cast
 * @ return The object as a double */
public static Double castDouble ( Object o ) { } }

implementation: if ( o == null ) { return null ; } if ( o instanceof Number ) { return ( ( Number ) o ) . doubleValue ( ) ; } try { return Double . valueOf ( o . toString ( ) ) ; } catch ( NumberFormatException e ) { return null ; }


signature:
public class GenericMath { /** * Casts a value to a long . May return null .
 * @ param o The object to attempt to cast
 * @ return The object as a long */
public static Long castLong ( Object o ) { } }

implementation: if ( o == null ) { return null ; } if ( o instanceof Number ) { return ( ( Number ) o ) . longValue ( ) ; } try { return Long . valueOf ( o . toString ( ) ) ; } catch ( NumberFormatException e ) { return null ; }


signature:
public class GenericMath { /** * Casts a value to a boolean . May return null .
 * @ param o The object to attempt to cast
 * @ return The object as a boolean */
public static Boolean castBoolean ( Object o ) { } }

implementation: if ( o == null ) { return null ; } if ( o instanceof Boolean ) { return ( Boolean ) o ; } else if ( o instanceof String ) { try { return Boolean . parseBoolean ( ( String ) o ) ; } catch ( IllegalArgumentException e ) { return null ; } } return null ;


signature:
public class GenericMath { /** * Calculates the mean of a set of values
 * @ param values to calculate the mean of
 * @ return the mean of the values */
public static int mean ( int ... values ) { } }

implementation: int sum = 0 ; for ( int v : values ) { sum += v ; } return sum / values . length ;


signature:
public class GenericMath { /** * Converts an integer to hexadecimal form with at least the minimum of digits specified ( by adding leading zeros ) .
 * @ param dec The integer to convert
 * @ param minDigits The minimum of digits in the hexadecimal form
 * @ return The integer in hexadecimal form */
public static String decToHex ( int dec , int minDigits ) { } }

implementation: String ret = Integer . toHexString ( dec ) ; while ( ret . length ( ) < minDigits ) { ret = '0' + ret ; } return ret ;


signature:
public class GenericMath { /** * Returns the modulo of ' a ' by ' div ' with corrections for negative numbers .
 * @ param a The dividend
 * @ param div The divider
 * @ return The corrected modulo */
public static double mod ( double a , double div ) { } }

implementation: final double remainder = a % div ; return remainder < 0 ? remainder + div : remainder ;


signature:
public class GenericMath { /** * Converts a multiplication into a shift .
 * @ param a the multiplicand
 * @ return the left shift required to multiply by the multiplicand */
public static int multiplyToShift ( int a ) { } }

implementation: if ( a < 1 ) { throw new IllegalArgumentException ( "Multiplicand must be at least 1" ) ; } int shift = 31 - Integer . numberOfLeadingZeros ( a ) ; if ( ( 1 << shift ) != a ) { throw new IllegalArgumentException ( "Multiplicand must be a power of 2" ) ; } return shift ;


signature:
public class GenericMath { /** * Attempts to normalize a vector . If this fails , the method catches the exception and return a zero vector of the same dimension instead .
 * @ param v The vector to attempt to normalize
 * @ return The normalized vector , or the zero vector if it couldn ' t be normalized . */
public static Vector2f normalizeSafe ( Vector2f v ) { } }

implementation: try { return v . normalize ( ) ; } catch ( ArithmeticException ex ) { return Vector2f . ZERO ; }


signature:
public class GenericMath { /** * Attempts to normalize a vector . If this fails , the method catches the exception and return a zero vector of the same dimension instead .
 * @ param v The vector to attempt to normalize
 * @ return The normalized vector , or the zero vector if it couldn ' t be normalized . */
public static Vector2d normalizeSafe ( Vector2d v ) { } }

implementation: try { return v . normalize ( ) ; } catch ( ArithmeticException ex ) { return Vector2d . ZERO ; }


signature:
public class GenericMath { /** * Attempts to normalize a vector . If this fails , the method catches the exception and return a zero vector of the same dimension instead .
 * @ param v The vector to attempt to normalize
 * @ return The normalized vector , or the zero vector if it couldn ' t be normalized . */
public static Vector3f normalizeSafe ( Vector3f v ) { } }

implementation: try { return v . normalize ( ) ; } catch ( ArithmeticException ex ) { return Vector3f . ZERO ; }


signature:
public class GenericMath { /** * Attempts to normalize a vector . If this fails , the method catches the exception and return a zero vector of the same dimension instead .
 * @ param v The vector to attempt to normalize
 * @ return The normalized vector , or the zero vector if it couldn ' t be normalized . */
public static Vector3d normalizeSafe ( Vector3d v ) { } }

implementation: try { return v . normalize ( ) ; } catch ( ArithmeticException ex ) { return Vector3d . ZERO ; }


signature:
public class GenericMath { /** * Attempts to normalize a vector . If this fails , the method catches the exception and return a zero vector of the same dimension instead .
 * @ param v The vector to attempt to normalize
 * @ return The normalized vector , or the zero vector if it couldn ' t be normalized . */
public static Vector4f normalizeSafe ( Vector4f v ) { } }

implementation: try { return v . normalize ( ) ; } catch ( ArithmeticException ex ) { return Vector4f . ZERO ; }


signature:
public class GenericMath { /** * Attempts to normalize a vector . If this fails , the method catches the exception and return a zero vector of the same dimension instead .
 * @ param v The vector to attempt to normalize
 * @ return The normalized vector , or the zero vector if it couldn ' t be normalized . */
public static Vector4d normalizeSafe ( Vector4d v ) { } }

implementation: try { return v . normalize ( ) ; } catch ( ArithmeticException ex ) { return Vector4d . ZERO ; }


signature:
public class GenericMath { /** * Attempts to normalize a vector . If this fails , the method catches the exception and return a zero vector of the same dimension instead .
 * @ param v The vector to attempt to normalize
 * @ return The normalized vector , or the zero vector if it couldn ' t be normalized . */
public static VectorNf normalizeSafe ( VectorNf v ) { } }

implementation: try { return v . normalize ( ) ; } catch ( ArithmeticException ex ) { return new VectorNf ( v . size ( ) ) ; }


signature:
public class GenericMath { /** * Attempts to normalize a vector . If this fails , the method catches the exception and return a zero vector of the same dimension instead .
 * @ param v The vector to attempt to normalize
 * @ return The normalized vector , or the zero vector if it couldn ' t be normalized . */
public static VectorNd normalizeSafe ( VectorNd v ) { } }

implementation: try { return v . normalize ( ) ; } catch ( ArithmeticException ex ) { return new VectorNd ( v . size ( ) ) ; }


signature:
public class Quaterniond { /** * Adds another quaternion to this one .
 * @ param q The quaternion to add
 * @ return A new quaternion , which is the sum of both */
public Quaterniond add ( Quaterniond q ) { } }

implementation: return add ( q . x , q . y , q . z , q . w ) ;


signature:
public class Quaterniond { /** * Adds the double components of another quaternion to this one .
 * @ param x The x ( imaginary ) component of the quaternion to add
 * @ param y The y ( imaginary ) component of the quaternion to add
 * @ param z The z ( imaginary ) component of the quaternion to add
 * @ param w The w ( real ) component of the quaternion to add
 * @ return A new quaternion , which is the sum of both */
public Quaterniond add ( double x , double y , double z , double w ) { } }

implementation: return new Quaterniond ( this . x + x , this . y + y , this . z + z , this . w + w ) ;


signature:
public class Quaterniond { /** * Subtracts another quaternion from this one .
 * @ param q The quaternion to subtract
 * @ return A new quaternion , which is the difference of both */
public Quaterniond sub ( Quaterniond q ) { } }

implementation: return sub ( q . x , q . y , q . z , q . w ) ;


signature:
public class Quaterniond { /** * Subtracts the float components of another quaternion from this one .
 * @ param x The x ( imaginary ) component of the quaternion to subtract
 * @ param y The y ( imaginary ) component of the quaternion to subtract
 * @ param z The z ( imaginary ) component of the quaternion to subtract
 * @ param w The w ( real ) component of the quaternion to subtract
 * @ return A new quaternion , which is the difference of both */
public Quaterniond sub ( float x , float y , float z , float w ) { } }

implementation: return sub ( ( double ) x , ( double ) y , ( double ) z , ( double ) w ) ;


signature:
public class Quaterniond { /** * Subtracts the double components of another quaternion from this one .
 * @ param x The x ( imaginary ) component of the quaternion to subtract
 * @ param y The y ( imaginary ) component of the quaternion to subtract
 * @ param z The z ( imaginary ) component of the quaternion to subtract
 * @ param w The w ( real ) component of the quaternion to subtract
 * @ return A new quaternion , which is the difference of both */
public Quaterniond sub ( double x , double y , double z , double w ) { } }

implementation: return new Quaterniond ( this . x - x , this . y - y , this . z - z , this . w - w ) ;


signature:
public class Quaterniond { /** * Multiplies the components of this quaternion by a double scalar .
 * @ param a The multiplication scalar
 * @ return A new quaternion , which has each component multiplied by the scalar */
@ Override public Quaterniond mul ( double a ) { } }

implementation: return new Quaterniond ( x * a , y * a , z * a , w * a ) ;


signature:
public class Quaterniond { /** * Multiplies another quaternion with this one .
 * @ param q The quaternion to multiply with
 * @ return A new quaternion , which is the product of both */
public Quaterniond mul ( Quaterniond q ) { } }

implementation: return mul ( q . x , q . y , q . z , q . w ) ;


signature:
public class Quaterniond { /** * Multiplies the float components of another quaternion with this one .
 * @ param x The x ( imaginary ) component of the quaternion to multiply with
 * @ param y The y ( imaginary ) component of the quaternion to multiply with
 * @ param z The z ( imaginary ) component of the quaternion to multiply with
 * @ param w The w ( real ) component of the quaternion to multiply with
 * @ return A new quaternion , which is the product of both */
public Quaterniond mul ( float x , float y , float z , float w ) { } }

implementation: return mul ( ( double ) x , ( double ) y , ( double ) z , ( double ) w ) ;


signature:
public class Quaterniond { /** * Multiplies the double components of another quaternion with this one .
 * @ param x The x ( imaginary ) component of the quaternion to multiply with
 * @ param y The y ( imaginary ) component of the quaternion to multiply with
 * @ param z The z ( imaginary ) component of the quaternion to multiply with
 * @ param w The w ( real ) component of the quaternion to multiply with
 * @ return A new quaternion , which is the product of both */
public Quaterniond mul ( double x , double y , double z , double w ) { } }

implementation: return new Quaterniond ( this . w * x + this . x * w + this . y * z - this . z * y , this . w * y + this . y * w + this . z * x - this . x * z , this . w * z + this . z * w + this . x * y - this . y * x , this . w * w - this . x * x - this . y * y - this . z * z ) ;


signature:
public class Quaterniond { /** * Divides the components of this quaternion by a double scalar .
 * @ param a The division scalar
 * @ return A new quaternion , which has each component divided by the scalar */
@ Override public Quaterniond div ( double a ) { } }

implementation: return new Quaterniond ( x / a , y / a , z / a , w / a ) ;


signature:
public class Quaterniond { /** * Divides this quaternions by another one .
 * @ param q The quaternion to divide with
 * @ return The quotient of the two quaternions */
public Quaterniond div ( Quaterniond q ) { } }

implementation: return div ( q . x , q . y , q . z , q . w ) ;


signature:
public class Quaterniond { /** * Divides this quaternions by the float components of another one .
 * @ param x The x ( imaginary ) component of the quaternion to divide with
 * @ param y The y ( imaginary ) component of the quaternion to divide with
 * @ param z The z ( imaginary ) component of the quaternion to divide with
 * @ param w The w ( real ) component of the quaternion to divide with
 * @ return The quotient of the two quaternions */
public Quaterniond div ( float x , float y , float z , float w ) { } }

implementation: return div ( ( double ) x , ( double ) y , ( double ) z , ( double ) w ) ;


signature:
public class Quaterniond { /** * Divides this quaternions by the double components of another one .
 * @ param x The x ( imaginary ) component of the quaternion to divide with
 * @ param y The y ( imaginary ) component of the quaternion to divide with
 * @ param z The z ( imaginary ) component of the quaternion to divide with
 * @ param w The w ( real ) component of the quaternion to divide with
 * @ return The quotient of the two quaternions */
public Quaterniond div ( double x , double y , double z , double w ) { } }

implementation: final double d = x * x + y * y + z * z + w * w ; return new Quaterniond ( ( this . x * w - this . w * x - this . z * y + this . y * z ) / d , ( this . y * w + this . z * x - this . w * y - this . x * z ) / d , ( this . z * w - this . y * x + this . x * y - this . w * z ) / d , ( this . w * w + this . x * x + this . y * y + this . z * z ) / d ) ;


signature:
public class Quaterniond { /** * Returns the dot product of this quaternion with another one .
 * @ param q The quaternion to calculate the dot product with
 * @ return The dot product of the two quaternions */
public double dot ( Quaterniond q ) { } }

implementation: return dot ( q . x , q . y , q . z , q . w ) ;


signature:
public class Quaterniond { /** * Rotates a vector by this quaternion .
 * @ param v The vector to rotate
 * @ return The rotated vector */
public Vector3d rotate ( Vector3d v ) { } }

implementation: return rotate ( v . getX ( ) , v . getY ( ) , v . getZ ( ) ) ;


signature:
public class Quaterniond { /** * Rotates the double components of a vector by this quaternion .
 * @ param x The x component of the vector
 * @ param y The y component of the vector
 * @ param z The z component of the vector
 * @ return The rotated vector */
public Vector3d rotate ( double x , double y , double z ) { } }

implementation: final double length = length ( ) ; if ( Math . abs ( length ) < GenericMath . DBL_EPSILON ) { throw new ArithmeticException ( "Cannot rotate by the zero quaternion" ) ; } final double nx = this . x / length ; final double ny = this . y / length ; final double nz = this . z / length ; final double nw = this . w / length ; final double px = nw * x + ny * z - nz * y ; final double py = nw * y + nz * x - nx * z ; final double pz = nw * z + nx * y - ny * x ; final double pw = - nx * x - ny * y - nz * z ; return new Vector3d ( pw * - nx + px * nw - py * nz + pz * ny , pw * - ny + py * nw - pz * nx + px * nz , pw * - nz + pz * nw - px * ny + py * nx ) ;


signature:
public class Quaterniond { /** * Returns the square of the length of this quaternion .
 * @ return The square of the length */
@ Override public double lengthSquared ( ) { } }

implementation: return x * x + y * y + z * z + w * w ;


signature:
public class Quaterniond { /** * Normalizes this quaternion .
 * @ return A new quaternion of unit length */
@ Override public Quaterniond normalize ( ) { } }

implementation: final double length = length ( ) ; if ( Math . abs ( length ) < GenericMath . DBL_EPSILON ) { throw new ArithmeticException ( "Cannot normalize the zero quaternion" ) ; } return new Quaterniond ( x / length , y / length , z / length , w / length ) ;


signature:
public class Quaterniond { /** * Converts this quaternion to a complex by extracting the rotation around
 * the axis and returning it as a rotation in the plane perpendicular to the
 * rotation axis .
 * @ return The rotation without the axis as a complex */
public Complexd toComplex ( ) { } }

implementation: final double w2 = w * w ; return new Complexd ( 2 * w2 - 1 , 2 * w * ( double ) Math . sqrt ( 1 - w2 ) ) ;


signature:
public class Quaterniond { /** * Creates a new quaternion from the double imaginary components .
 * < p > The { @ link # ZERO } constant is re - used when { @ code x } , { @ code y } , and { @ code z } are 0 . < / p >
 * @ param x The x ( imaginary ) component
 * @ param y The y ( imaginary ) component
 * @ param z The z ( imaginary ) component
 * @ return The quaternion created from the double imaginary components */
public static Quaterniond fromImaginary ( double x , double y , double z ) { } }

implementation: return x == 0 && y == 0 && z == 0 ? ZERO : new Quaterniond ( x , y , z , 0 ) ;


signature:
public class Quaterniond { /** * Creates a new quaternion from the double components .
 * < p > The { @ link # ZERO } constant is re - used when { @ code x } , { @ code y } , { @ code z } , and { @ code w } are 0 . < / p >
 * @ param x The x ( imaginary ) component
 * @ param y The y ( imaginary ) component
 * @ param z The z ( imaginary ) component
 * @ param w The w ( real ) component
 * @ return The quaternion created from the double components */
public static Quaterniond from ( double x , double y , double z , double w ) { } }

implementation: return x == 0 && y == 0 && z == 0 && w == 0 ? ZERO : new Quaterniond ( x , y , z , w ) ;


signature:
public class Quaterniond { /** * Creates a new quaternion from the double angles in degrees around the x , y and z axes .
 * @ param pitch The rotation around x
 * @ param yaw The rotation around y
 * @ param roll The rotation around z
 * @ return The quaternion defined by the rotations around the axes */
public static Quaterniond fromAxesAnglesDeg ( double pitch , double yaw , double roll ) { } }

implementation: return Quaterniond . fromAngleDegAxis ( yaw , Vector3d . UNIT_Y ) . mul ( Quaterniond . fromAngleDegAxis ( pitch , Vector3d . UNIT_X ) ) . mul ( Quaterniond . fromAngleDegAxis ( roll , Vector3d . UNIT_Z ) ) ;


signature:
public class Quaterniond { /** * Creates a new quaternion from the double angles in radians around the x , y and z axes .
 * @ param pitch The rotation around x
 * @ param yaw The rotation around y
 * @ param roll The rotation around z
 * @ return The quaternion defined by the rotations around the axes */
public static Quaterniond fromAxesAnglesRad ( double pitch , double yaw , double roll ) { } }

implementation: return Quaterniond . fromAngleRadAxis ( yaw , Vector3d . UNIT_Y ) . mul ( Quaterniond . fromAngleRadAxis ( pitch , Vector3d . UNIT_X ) ) . mul ( Quaterniond . fromAngleRadAxis ( roll , Vector3d . UNIT_Z ) ) ;


signature:
public class Quaterniond { /** * Creates a new quaternion from the angle - axis rotation defined from the first to the second vector .
 * @ param from The first vector
 * @ param to The second vector
 * @ return The quaternion defined by the angle - axis rotation between the vectors */
public static Quaterniond fromRotationTo ( Vector3d from , Vector3d to ) { } }

implementation: return Quaterniond . fromAngleRadAxis ( TrigMath . acos ( from . dot ( to ) / ( from . length ( ) * to . length ( ) ) ) , from . cross ( to ) ) ;


signature:
public class Quaterniond { /** * Creates a new quaternion from the rotation double angle in degrees around the axis vector .
 * @ param angle The rotation angle in degrees
 * @ param axis The axis of rotation
 * @ return The quaternion defined by the rotation around the axis */
public static Quaterniond fromAngleDegAxis ( double angle , Vector3d axis ) { } }

implementation: return fromAngleRadAxis ( ( double ) Math . toRadians ( angle ) , axis ) ;


signature:
public class Quaterniond { /** * Creates a new quaternion from the rotation double angle in radians around the axis vector .
 * @ param angle The rotation angle in radians
 * @ param axis The axis of rotation
 * @ return The quaternion defined by the rotation around the axis */
public static Quaterniond fromAngleRadAxis ( double angle , Vector3d axis ) { } }

implementation: return fromAngleRadAxis ( angle , axis . getX ( ) , axis . getY ( ) , axis . getZ ( ) ) ;


signature:
public class Quaterniond { /** * Creates a new quaternion from the rotation float angle in degrees around the axis vector float components .
 * @ param angle The rotation angle in degrees
 * @ param x The x component of the axis vector
 * @ param y The y component of the axis vector
 * @ param z The z component of the axis vector
 * @ return The quaternion defined by the rotation around the axis */
public static Quaterniond fromAngleDegAxis ( float angle , float x , float y , float z ) { } }

implementation: return fromAngleRadAxis ( Math . toRadians ( angle ) , x , y , z ) ;


signature:
public class Quaterniond { /** * Creates a new quaternion from the rotation float angle in radians around the axis vector float components .
 * @ param angle The rotation angle in radians
 * @ param x The x component of the axis vector
 * @ param y The y component of the axis vector
 * @ param z The z component of the axis vector
 * @ return The quaternion defined by the rotation around the axis */
public static Quaterniond fromAngleRadAxis ( float angle , float x , float y , float z ) { } }

implementation: return fromAngleRadAxis ( ( double ) angle , ( double ) x , ( double ) y , ( double ) z ) ;


signature:
public class Quaterniond { /** * Creates a new quaternion from the rotation matrix . The matrix will be interpreted as a rotation matrix even if it is not .
 * @ param matrix The rotation matrix
 * @ return The quaternion defined by the rotation matrix */
public static Quaterniond fromRotationMatrix ( Matrix3d matrix ) { } }

implementation: final double trace = matrix . trace ( ) ; if ( trace < 0 ) { if ( matrix . get ( 1 , 1 ) > matrix . get ( 0 , 0 ) ) { if ( matrix . get ( 2 , 2 ) > matrix . get ( 1 , 1 ) ) { final double r = ( double ) Math . sqrt ( matrix . get ( 2 , 2 ) - matrix . get ( 0 , 0 ) - matrix . get ( 1 , 1 ) + 1 ) ; final double s = 0.5f / r ; return new Quaterniond ( ( matrix . get ( 2 , 0 ) + matrix . get ( 0 , 2 ) ) * s , ( matrix . get ( 1 , 2 ) + matrix . get ( 2 , 1 ) ) * s , 0.5f * r , ( matrix . get ( 1 , 0 ) - matrix . get ( 0 , 1 ) ) * s ) ; } else { final double r = ( double ) Math . sqrt ( matrix . get ( 1 , 1 ) - matrix . get ( 2 , 2 ) - matrix . get ( 0 , 0 ) + 1 ) ; final double s = 0.5f / r ; return new Quaterniond ( ( matrix . get ( 0 , 1 ) + matrix . get ( 1 , 0 ) ) * s , 0.5f * r , ( matrix . get ( 1 , 2 ) + matrix . get ( 2 , 1 ) ) * s , ( matrix . get ( 0 , 2 ) - matrix . get ( 2 , 0 ) ) * s ) ; } } else if ( matrix . get ( 2 , 2 ) > matrix . get ( 0 , 0 ) ) { final double r = ( double ) Math . sqrt ( matrix . get ( 2 , 2 ) - matrix . get ( 0 , 0 ) - matrix . get ( 1 , 1 ) + 1 ) ; final double s = 0.5f / r ; return new Quaterniond ( ( matrix . get ( 2 , 0 ) + matrix . get ( 0 , 2 ) ) * s , ( matrix . get ( 1 , 2 ) + matrix . get ( 2 , 1 ) ) * s , 0.5f * r , ( matrix . get ( 1 , 0 ) - matrix . get ( 0 , 1 ) ) * s ) ; } else { final double r = ( double ) Math . sqrt ( matrix . get ( 0 , 0 ) - matrix . get ( 1 , 1 ) - matrix . get ( 2 , 2 ) + 1 ) ; final double s = 0.5f / r ; return new Quaterniond ( 0.5f * r , ( matrix . get ( 0 , 1 ) + matrix . get ( 1 , 0 ) ) * s , ( matrix . get ( 2 , 0 ) - matrix . get ( 0 , 2 ) ) * s , ( matrix . get ( 2 , 1 ) - matrix . get ( 1 , 2 ) ) * s ) ; } } else { final double r = ( double ) Math . sqrt ( trace + 1 ) ; final double s = 0.5f / r ; return new Quaterniond ( ( matrix . get ( 2 , 1 ) - matrix . get ( 1 , 2 ) ) * s , ( matrix . get ( 0 , 2 ) - matrix . get ( 2 , 0 ) ) * s , ( matrix . get ( 1 , 0 ) - matrix . get ( 0 , 1 ) ) * s , 0.5f * r ) ; }


signature:
public class Matrix4d { /** * Creates a " look at " matrix for the given eye point .
 * @ param eye The position of the camera
 * @ param at The point that the camera is looking at
 * @ param up The " up " vector
 * @ return A rotational transform that corresponds to a camera looking at the given point */
public static Matrix4d createLookAt ( Vector3d eye , Vector3d at , Vector3d up ) { } }

implementation: final Vector3d f = at . sub ( eye ) . normalize ( ) ; final Vector3d s = f . cross ( up ) . normalize ( ) ; final Vector3d u = s . cross ( f ) ; final Matrix4d mat = new Matrix4d ( s . getX ( ) , s . getY ( ) , s . getZ ( ) , 0 , u . getX ( ) , u . getY ( ) , u . getZ ( ) , 0 , - f . getX ( ) , - f . getY ( ) , - f . getZ ( ) , 0 , 0 , 0 , 0 , 1 ) ; return mat . translate ( eye . negate ( ) ) ;


signature:
public class Matrix4d { /** * Creates a perspective projection matrix with the given ( x ) FOV , aspect , near and far planes
 * @ param fov The field of view in the x direction
 * @ param aspect The aspect ratio , usually width / height
 * @ param near The near plane , cannot be 0
 * @ param far the far plane , far cannot equal near
 * @ return A perspective projection matrix built from the given values */
public static Matrix4d createPerspective ( float fov , float aspect , float near , float far ) { } }

implementation: return createPerspective ( ( double ) fov , ( double ) aspect , ( double ) near , ( double ) far ) ;


signature:
public class Matrix4d { /** * Creates a perspective projection matrix with the given ( x ) FOV , aspect , near and far planes
 * @ param fov The field of view in the x direction
 * @ param aspect The aspect ratio , usually width / height
 * @ param near The near plane , cannot be 0
 * @ param far the far plane , far cannot equal near
 * @ return A perspective projection matrix built from the given values */
public static Matrix4d createPerspective ( double fov , double aspect , double near , double far ) { } }

implementation: final double scale = 1 / TrigMath . tan ( fov * ( double ) TrigMath . HALF_DEG_TO_RAD ) ; return new Matrix4d ( scale / aspect , 0 , 0 , 0 , 0 , scale , 0 , 0 , 0 , 0 , ( far + near ) / ( near - far ) , 2 * far * near / ( near - far ) , 0 , 0 , - 1 , 0 ) ;


signature:
public class Matrix4d { /** * Creates an orthographic viewing frustum built from the provided values
 * @ param right the right most plane of the viewing frustum
 * @ param left the left most plane of the viewing frustum
 * @ param top the top plane of the viewing frustum
 * @ param bottom the bottom plane of the viewing frustum
 * @ param near the near plane of the viewing frustum
 * @ param far the far plane of the viewing frustum
 * @ return A viewing frustum built from the provided values */
public static Matrix4d createOrthographic ( float right , float left , float top , float bottom , float near , float far ) { } }

implementation: return createOrthographic ( ( double ) right , ( double ) left , ( double ) top , ( double ) bottom , ( double ) near , ( double ) far ) ;


signature:
public class Matrix4d { /** * Creates an orthographic viewing frustum built from the provided values
 * @ param right the right most plane of the viewing frustum
 * @ param left the left most plane of the viewing frustum
 * @ param top the top plane of the viewing frustum
 * @ param bottom the bottom plane of the viewing frustum
 * @ param near the near plane of the viewing frustum
 * @ param far the far plane of the viewing frustum
 * @ return A viewing frustum built from the provided values */
public static Matrix4d createOrthographic ( double right , double left , double top , double bottom , double near , double far ) { } }

implementation: return new Matrix4d ( 2 / ( right - left ) , 0 , 0 , - ( right + left ) / ( right - left ) , 0 , 2 / ( top - bottom ) , 0 , - ( top + bottom ) / ( top - bottom ) , 0 , 0 , - 2 / ( far - near ) , - ( far + near ) / ( far - near ) , 0 , 0 , 0 , 1 ) ;


signature:
public class Vector3d { /** * Gets the direction vector of a random pitch and yaw using the random specified .
 * @ param random to use
 * @ return the random direction vector */
public static Vector3d createRandomDirection ( Random random ) { } }

implementation: return createDirectionRad ( random . nextDouble ( ) * ( double ) TrigMath . TWO_PI , random . nextDouble ( ) * ( double ) TrigMath . TWO_PI ) ;


signature:
public class Vector3d { /** * Gets the direction vector of a certain theta and phi in degrees . This uses the standard math spherical coordinate system .
 * @ param theta in degrees
 * @ param phi in degrees
 * @ return the direction vector */
public static Vector3d createDirectionDeg ( double theta , double phi ) { } }

implementation: return createDirectionRad ( ( double ) Math . toRadians ( theta ) , ( double ) Math . toRadians ( phi ) ) ;


signature:
public class Vector3d { /** * Gets the direction vector of a certain theta and phi in radians . This uses the standard math spherical coordinate system .
 * @ param theta in radians
 * @ param phi in radians
 * @ return the direction vector */
public static Vector3d createDirectionRad ( double theta , double phi ) { } }

implementation: final double f = TrigMath . sin ( phi ) ; return new Vector3d ( f * TrigMath . cos ( theta ) , f * TrigMath . sin ( theta ) , TrigMath . cos ( phi ) ) ;


signature:
public class Vector4i { /** * Return the axis with the minimal value .
 * @ return { @ link int } axis with minimal value */
@ Override public int getMinAxis ( ) { } }

implementation: int value = x ; int axis = 0 ; if ( y < value ) { value = y ; axis = 1 ; } if ( z < value ) { value = z ; axis = 2 ; } if ( w < value ) { axis = 3 ; } return axis ;


signature:
public class Vector2d { /** * Gets the direction vector of a certain angle in radians .
 * @ param angle in radians
 * @ return the direction vector */
public static Vector2d createDirectionRad ( double angle ) { } }

implementation: return new Vector2d ( TrigMath . cos ( angle ) , TrigMath . sin ( angle ) ) ;


signature:
public class MatrixNd { /** * Creates a " look at " matrix for the given eye point .
 * @ param size The size of the matrix , minimum of 4
 * @ param eye The position of the camera
 * @ param at The point that the camera is looking at
 * @ param up The " up " vector
 * @ return A rotational transform that corresponds to a camera looking at the given point */
public static MatrixNd createLookAt ( int size , Vector3d eye , Vector3d at , Vector3d up ) { } }

implementation: if ( size < 4 ) { throw new IllegalArgumentException ( "Minimum matrix size is 4" ) ; } final Vector3d f = at . sub ( eye ) . normalize ( ) ; up = up . normalize ( ) ; final Vector3d s = f . cross ( up ) . normalize ( ) ; final Vector3d u = s . cross ( f ) . normalize ( ) ; final MatrixNd mat = new MatrixNd ( size ) ; mat . set ( 0 , 0 , s . getX ( ) ) ; mat . set ( 0 , 1 , s . getY ( ) ) ; mat . set ( 0 , 2 , s . getZ ( ) ) ; mat . set ( 1 , 0 , u . getX ( ) ) ; mat . set ( 1 , 1 , u . getY ( ) ) ; mat . set ( 1 , 2 , u . getZ ( ) ) ; mat . set ( 2 , 0 , - f . getX ( ) ) ; mat . set ( 2 , 1 , - f . getY ( ) ) ; mat . set ( 2 , 2 , - f . getZ ( ) ) ; return mat . translate ( eye . mul ( - 1 ) . toVectorN ( ) ) ;


signature:
public class MatrixNd { /** * Creates a perspective projection matrix with the given ( x ) FOV , aspect , near and far planes
 * @ param size The size of the matrix , minimum of 4
 * @ param fov The field of view in the x direction
 * @ param aspect The aspect ratio , usually width / height
 * @ param near The near plane , cannot be 0
 * @ param far the far plane , zFar cannot equal zNear
 * @ return A perspective projection matrix built from the given values */
public static MatrixNd createPerspective ( int size , float fov , float aspect , float near , float far ) { } }

implementation: return createPerspective ( size , ( double ) fov , ( double ) aspect , ( double ) near , ( double ) far ) ;


signature:
public class MatrixNd { /** * Creates a perspective projection matrix with the given ( x ) FOV , aspect , near and far planes
 * @ param size The size of the matrix , minimum of 4
 * @ param fov The field of view in the x direction
 * @ param aspect The aspect ratio , usually width / height
 * @ param near The near plane , cannot be 0
 * @ param far the far plane , zFar cannot equal zNear
 * @ return A perspective projection matrix built from the given values */
public static MatrixNd createPerspective ( int size , double fov , double aspect , double near , double far ) { } }

implementation: if ( size < 4 ) { throw new IllegalArgumentException ( "Minimum matrix size is 4" ) ; } final MatrixNd perspective = new MatrixNd ( size ) ; final double scale = 1 / TrigMath . tan ( fov * ( double ) TrigMath . HALF_DEG_TO_RAD ) ; perspective . set ( 0 , 0 , scale / aspect ) ; perspective . set ( 1 , 1 , scale ) ; perspective . set ( 2 , 2 , ( far + near ) / ( near - far ) ) ; perspective . set ( 2 , 3 , 2 * far * near / ( near - far ) ) ; perspective . set ( 3 , 2 , - 1 ) ; perspective . set ( 3 , 3 , 0 ) ; return perspective ;


signature:
public class MatrixNd { /** * Creates an orthographic viewing frustum built from the provided values
 * @ param size The size of the matrix , minimum of 4
 * @ param right the right most plane of the viewing frustum
 * @ param left the left most plane of the viewing frustum
 * @ param top the top plane of the viewing frustum
 * @ param bottom the bottom plane of the viewing frustum
 * @ param near the near plane of the viewing frustum
 * @ param far the far plane of the viewing frustum
 * @ return A viewing frustum built from the provided values */
public static MatrixNd createOrthographic ( int size , float right , float left , float top , float bottom , float near , float far ) { } }

implementation: return createOrthographic ( size , ( double ) right , ( double ) left , ( double ) top , ( double ) bottom , ( double ) near , ( double ) far ) ;


signature:
public class MatrixNd { /** * Creates an orthographic viewing frustum built from the provided values
 * @ param size The size of the matrix , minimum of 4
 * @ param right the right most plane of the viewing frustum
 * @ param left the left most plane of the viewing frustum
 * @ param top the top plane of the viewing frustum
 * @ param bottom the bottom plane of the viewing frustum
 * @ param near the near plane of the viewing frustum
 * @ param far the far plane of the viewing frustum
 * @ return A viewing frustum built from the provided values */
public static MatrixNd createOrthographic ( int size , double right , double left , double top , double bottom , double near , double far ) { } }

implementation: if ( size < 4 ) { throw new IllegalArgumentException ( "Minimum matrix size is 4" ) ; } final MatrixNd orthographic = new MatrixNd ( size ) ; orthographic . set ( 0 , 0 , 2 / ( right - left ) ) ; orthographic . set ( 1 , 1 , 2 / ( top - bottom ) ) ; orthographic . set ( 2 , 2 , - 2 / ( far - near ) ) ; orthographic . set ( 0 , 3 , - ( right + left ) / ( right - left ) ) ; orthographic . set ( 1 , 3 , - ( top + bottom ) / ( top - bottom ) ) ; orthographic . set ( 2 , 3 , - ( far + near ) / ( far - near ) ) ; return orthographic ;


signature:
public class Matrix4f { /** * Creates a " look at " matrix for the given eye point .
 * @ param eye The position of the camera
 * @ param at The point that the camera is looking at
 * @ param up The " up " vector
 * @ return A rotational transform that corresponds to a camera looking at the given point */
public static Matrix4f createLookAt ( Vector3f eye , Vector3f at , Vector3f up ) { } }

implementation: final Vector3f f = at . sub ( eye ) . normalize ( ) ; final Vector3f s = f . cross ( up ) . normalize ( ) ; final Vector3f u = s . cross ( f ) ; final Matrix4f mat = new Matrix4f ( s . getX ( ) , s . getY ( ) , s . getZ ( ) , 0 , u . getX ( ) , u . getY ( ) , u . getZ ( ) , 0 , - f . getX ( ) , - f . getY ( ) , - f . getZ ( ) , 0 , 0 , 0 , 0 , 1 ) ; return mat . translate ( eye . negate ( ) ) ;


signature:
public class Matrix4f { /** * Creates a perspective projection matrix with the given ( x ) FOV , aspect , near and far planes
 * @ param fov The field of view in the x direction
 * @ param aspect The aspect ratio , usually width / height
 * @ param near The near plane , cannot be 0
 * @ param far the far plane , far cannot equal near
 * @ return A perspective projection matrix built from the given values */
public static Matrix4f createPerspective ( double fov , double aspect , double near , double far ) { } }

implementation: return createPerspective ( ( float ) fov , ( float ) aspect , ( float ) near , ( float ) far ) ;


signature:
public class Matrix4f { /** * Creates an orthographic viewing frustum built from the provided values
 * @ param right the right most plane of the viewing frustum
 * @ param left the left most plane of the viewing frustum
 * @ param top the top plane of the viewing frustum
 * @ param bottom the bottom plane of the viewing frustum
 * @ param near the near plane of the viewing frustum
 * @ param far the far plane of the viewing frustum
 * @ return A viewing frustum built from the provided values */
public static Matrix4f createOrthographic ( double right , double left , double top , double bottom , double near , double far ) { } }

implementation: return createOrthographic ( ( float ) right , ( float ) left , ( float ) top , ( float ) bottom , ( float ) near , ( float ) far ) ;


signature:
public class Matrix4f { /** * Creates an orthographic viewing frustum built from the provided values
 * @ param right the right most plane of the viewing frustum
 * @ param left the left most plane of the viewing frustum
 * @ param top the top plane of the viewing frustum
 * @ param bottom the bottom plane of the viewing frustum
 * @ param near the near plane of the viewing frustum
 * @ param far the far plane of the viewing frustum
 * @ return A viewing frustum built from the provided values */
public static Matrix4f createOrthographic ( float right , float left , float top , float bottom , float near , float far ) { } }

implementation: return new Matrix4f ( 2 / ( right - left ) , 0 , 0 , - ( right + left ) / ( right - left ) , 0 , 2 / ( top - bottom ) , 0 , - ( top + bottom ) / ( top - bottom ) , 0 , 0 , - 2 / ( far - near ) , - ( far + near ) / ( far - near ) , 0 , 0 , 0 , 1 ) ;


signature:
public class Complexf { /** * Multiplies the float components of another complex with this one .
 * @ param x The x ( real ) component of the complex to multiply with
 * @ param y The y ( imaginary ) component of the complex to multiply with
 * @ return A new complex , which is the product of both */
public Complexf mul ( float x , float y ) { } }

implementation: return new Complexf ( this . x * x - this . y * y , this . x * y + this . y * x ) ;


signature:
public class Complexf { /** * Divides this complex by the float components of another one .
 * @ param x The x ( real ) component of the complex to divide with
 * @ param y The y ( imaginary ) component of the complex to divide with
 * @ return The quotient of the two complexes */
public Complexf div ( float x , float y ) { } }

implementation: final float d = x * x + y * y ; return new Complexf ( ( this . x * x + this . y * y ) / d , ( this . y * x - this . x * y ) / d ) ;


signature:
public class Complexf { /** * Rotates the float components of a vector by this complex .
 * @ param x The x component of the vector
 * @ param y The y component of the vector
 * @ return The rotated vector */
public Vector2f rotate ( float x , float y ) { } }

implementation: final float length = length ( ) ; if ( Math . abs ( length ) < GenericMath . FLT_EPSILON ) { throw new ArithmeticException ( "Cannot rotate by the zero complex" ) ; } final float nx = this . x / length ; final float ny = this . y / length ; return new Vector2f ( x * nx - y * ny , y * nx + x * ny ) ;


signature:
public class Complexf { /** * Normalizes this complex .
 * @ return A new complex of unit length */
@ Override public Complexf normalize ( ) { } }

implementation: final float length = length ( ) ; if ( Math . abs ( length ) < GenericMath . FLT_EPSILON ) { throw new ArithmeticException ( "Cannot normalize the zero complex" ) ; } return new Complexf ( x / length , y / length ) ;


signature:
public class Complexf { /** * Converts this complex to a quaternion by
 * using the provided vector as a rotation axis .
 * @ param axis The rotation axis
 * @ return A quaternion of this rotation around the given axis */
public Quaternionf toQuaternion ( Vector3f axis ) { } }

implementation: return toQuaternion ( axis . getX ( ) , axis . getY ( ) , axis . getZ ( ) ) ;


signature:
public class Complexf { /** * Converts this complex to a quaternion by
 * using the provided float components vector
 * as a rotation axis .
 * @ param x The x component of the axis vector
 * @ param y The y component of the axis vector
 * @ param z The z component of the axis vector
 * @ return A quaternion of this rotation around the given axis */
public Quaternionf toQuaternion ( float x , float y , float z ) { } }

implementation: return Quaternionf . fromAngleRadAxis ( getAngleRad ( ) , x , y , z ) ;


signature:
public class Complexf { /** * Creates a new complex from the float components .
 * < p > The { @ link # ZERO } constant is re - used when both { @ code x } and { @ code z } are 0 . < / p >
 * @ param x The x ( real ) component
 * @ param y The y ( imaginary ) component
 * @ return The complex created from the float components */
public static Complexf from ( float x , float y ) { } }

implementation: return x == 0 && y == 0 ? ZERO : new Complexf ( x , y ) ;


signature:
public class Complexf { /** * Creates a new complex from the angle defined from the first to the second vector .
 * @ param from The first vector
 * @ param to The second vector
 * @ return The complex defined by the angle between the vectors */
public static Complexf fromRotationTo ( Vector2f from , Vector2f to ) { } }

implementation: return fromAngleRad ( TrigMath . acos ( from . dot ( to ) / ( from . length ( ) * to . length ( ) ) ) ) ;


signature:
public class Complexf { /** * Creates a new complex from the float angle in radians .
 * @ param angle The angle in radians
 * @ return The complex defined by the angle */
public static Complexf fromAngleRad ( float angle ) { } }

implementation: return new Complexf ( TrigMath . cos ( angle ) , TrigMath . sin ( angle ) ) ;


signature:
public class TrigMath { /** * Tangent calculations using a table . < br > < i > sin ( angle ) / cos ( angle ) < / i > < br > < br > < p / > < b > No interpolation is performed : < / b > Accuracy is up to the 6th decimal place
 * @ param angle in radians
 * @ return the tangent of the angle */
public static float tan ( double angle ) { } }

implementation: int idx = GenericMath . floor ( angle * SIN_CONVERSION_FACTOR ) ; return sinRaw ( idx ) / cosRaw ( idx ) ;


signature:
public class TrigMath { /** * Cotangent calculations using a table . < br > < i > cos ( angle ) / sin ( angle ) < / i > < br > < br > < p / > < b > No interpolation is performed : < / b > Accuracy is up to the 6th decimal place
 * @ param angle in radians
 * @ return the cotangent of the angle */
public static float cot ( double angle ) { } }

implementation: int idx = GenericMath . floor ( angle * SIN_CONVERSION_FACTOR ) ; return cosRaw ( idx ) / sinRaw ( idx ) ;


signature:
public class TrigMath { /** * Calculates the arc sine of the value specified < br > < br > Returns NaN if the input value is outside the sine range
 * @ param value of the sine
 * @ return sine arc in radians */
public static double asin ( double value ) { } }

implementation: if ( value > 1 ) { return Double . NaN ; } else if ( value < 0 ) { return - asin ( - value ) ; } else { double temp = Math . sqrt ( 1 - value * value ) ; if ( value > 0.7 ) { return HALF_PI - msatan ( temp / value ) ; } else { return msatan ( value / temp ) ; } }


signature:
public class TrigMath { /** * Computes the phase theta by computing an arc tangent of y / x < br > Gets the yaw rotation component in radians when looking into the direction specified
 * @ param y direction
 * @ param x direction
 * @ return tangent arc in radians */
public static double atan2 ( double y , double x ) { } }

implementation: if ( y + x == y ) { return y >= 0 ? HALF_PI : - HALF_PI ; } y = atan ( y / x ) ; if ( x < 0 ) { if ( y <= 0 ) { return y + PI ; } else { return y - PI ; } } return y ;


signature:
public class TrigMath { /** * Calculates the arc cotangent of the value specified < br > < br > Returns NaN if the input value is outside the cotangent range
 * @ param value of the cotangent
 * @ return cotangent arc in radians */
public static double acot ( double value ) { } }

implementation: if ( value == 0 ) { return Double . NaN ; } else if ( value > 0 ) { return atan ( 1 / value ) ; } else { return atan ( 1 / value ) + PI ; }


signature:
public class Vector4l { /** * Return the axis with the maximum value .
 * @ return { @ link int } axis with maximum value */
@ Override public int getMaxAxis ( ) { } }

implementation: long value = x ; int axis = 0 ; if ( y > value ) { value = y ; axis = 1 ; } if ( z > value ) { value = z ; axis = 2 ; } if ( w > value ) { axis = 3 ; } return axis ;


signature:
public class HashFunctions { /** * Returns a hashcode for the specified value .
 * @ return a hash code value for the specified value . */
public static int hash ( double value ) { } }

implementation:
assert ! Double . isNaN ( value ) : "Values of NaN are not supported." ; long bits = Double . doubleToLongBits ( value ) ; return ( int ) ( bits ^ ( bits >>> 32 ) ) ; // return ( int ) Double . doubleToLongBits ( value * 663608941.737 ) ;
// This avoids excessive hashCollisions in the case values are of the form ( 1.0 , 2.0 , 3.0 , . . . )


signature:
public class Quaternionf { /** * Adds another quaternion to this one .
 * @ param q The quaternion to add
 * @ return A new quaternion , which is the sum of both */
public Quaternionf add ( Quaternionf q ) { } }

implementation: return add ( q . x , q . y , q . z , q . w ) ;


signature:
public class Quaternionf { /** * Adds the double components of another quaternion to this one .
 * @ param x The x ( imaginary ) component of the quaternion to add
 * @ param y The y ( imaginary ) component of the quaternion to add
 * @ param z The z ( imaginary ) component of the quaternion to add
 * @ param w The w ( real ) component of the quaternion to add
 * @ return A new quaternion , which is the sum of both */
public Quaternionf add ( double x , double y , double z , double w ) { } }

implementation: return add ( ( float ) x , ( float ) y , ( float ) z , ( float ) w ) ;


signature:
public class Quaternionf { /** * Adds the float components of another quaternion to this one .
 * @ param x The x ( imaginary ) component of the quaternion to add
 * @ param y The y ( imaginary ) component of the quaternion to add
 * @ param z The z ( imaginary ) component of the quaternion to add
 * @ param w The w ( real ) component of the quaternion to add
 * @ return A new quaternion , which is the sum of both */
public Quaternionf add ( float x , float y , float z , float w ) { } }

implementation: return new Quaternionf ( this . x + x , this . y + y , this . z + z , this . w + w ) ;


signature:
public class Quaternionf { /** * Subtracts another quaternion from this one .
 * @ param q The quaternion to subtract
 * @ return A new quaternion , which is the difference of both */
public Quaternionf sub ( Quaternionf q ) { } }

implementation: return sub ( q . x , q . y , q . z , q . w ) ;


signature:
public class Quaternionf { /** * Subtracts the double components of another quaternion from this one .
 * @ param x The x ( imaginary ) component of the quaternion to subtract
 * @ param y The y ( imaginary ) component of the quaternion to subtract
 * @ param z The z ( imaginary ) component of the quaternion to subtract
 * @ param w The w ( real ) component of the quaternion to subtract
 * @ return A new quaternion , which is the difference of both */
public Quaternionf sub ( double x , double y , double z , double w ) { } }

implementation: return sub ( ( float ) x , ( float ) y , ( float ) z , ( float ) w ) ;


signature:
public class Quaternionf { /** * Subtracts the float components of another quaternion from this one .
 * @ param x The x ( imaginary ) component of the quaternion to subtract
 * @ param y The y ( imaginary ) component of the quaternion to subtract
 * @ param z The z ( imaginary ) component of the quaternion to subtract
 * @ param w The w ( real ) component of the quaternion to subtract
 * @ return A new quaternion , which is the difference of both */
public Quaternionf sub ( float x , float y , float z , float w ) { } }

implementation: return new Quaternionf ( this . x - x , this . y - y , this . z - z , this . w - w ) ;


signature:
public class Quaternionf { /** * Multiplies the components of this quaternion by a float scalar .
 * @ param a The multiplication scalar
 * @ return A new quaternion , which has each component multiplied by the scalar */
@ Override public Quaternionf mul ( float a ) { } }

implementation: return new Quaternionf ( x * a , y * a , z * a , w * a ) ;


signature:
public class Quaternionf { /** * Multiplies another quaternion with this one .
 * @ param q The quaternion to multiply with
 * @ return A new quaternion , which is the product of both */
public Quaternionf mul ( Quaternionf q ) { } }

implementation: return mul ( q . x , q . y , q . z , q . w ) ;


signature:
public class Quaternionf { /** * Multiplies the double components of another quaternion with this one .
 * @ param x The x ( imaginary ) component of the quaternion to multiply with
 * @ param y The y ( imaginary ) component of the quaternion to multiply with
 * @ param z The z ( imaginary ) component of the quaternion to multiply with
 * @ param w The w ( real ) component of the quaternion to multiply with
 * @ return A new quaternion , which is the product of both */
public Quaternionf mul ( double x , double y , double z , double w ) { } }

implementation: return mul ( ( float ) x , ( float ) y , ( float ) z , ( float ) w ) ;


signature:
public class Quaternionf { /** * Multiplies the float components of another quaternion with this one .
 * @ param x The x ( imaginary ) component of the quaternion to multiply with
 * @ param y The y ( imaginary ) component of the quaternion to multiply with
 * @ param z The z ( imaginary ) component of the quaternion to multiply with
 * @ param w The w ( real ) component of the quaternion to multiply with
 * @ return A new quaternion , which is the product of both */
public Quaternionf mul ( float x , float y , float z , float w ) { } }

implementation: return new Quaternionf ( this . w * x + this . x * w + this . y * z - this . z * y , this . w * y + this . y * w + this . z * x - this . x * z , this . w * z + this . z * w + this . x * y - this . y * x , this . w * w - this . x * x - this . y * y - this . z * z ) ;


signature:
public class Quaternionf { /** * Divides the components of this quaternion by a float scalar .
 * @ param a The division scalar
 * @ return A new quaternion , which has each component divided by the scalar */
@ Override public Quaternionf div ( float a ) { } }

implementation: return new Quaternionf ( x / a , y / a , z / a , w / a ) ;


signature:
public class Quaternionf { /** * Divides this quaternions by another one .
 * @ param q The quaternion to divide with
 * @ return The quotient of the two quaternions */
public Quaternionf div ( Quaternionf q ) { } }

implementation: return div ( q . x , q . y , q . z , q . w ) ;


signature:
public class Quaternionf { /** * Divides this quaternions by the double components of another one .
 * @ param x The x ( imaginary ) component of the quaternion to divide with
 * @ param y The y ( imaginary ) component of the quaternion to divide with
 * @ param z The z ( imaginary ) component of the quaternion to divide with
 * @ param w The w ( real ) component of the quaternion to divide with
 * @ return The quotient of the two quaternions */
public Quaternionf div ( double x , double y , double z , double w ) { } }

implementation: return div ( ( float ) x , ( float ) y , ( float ) z , ( float ) w ) ;


signature:
public class Quaternionf { /** * Divides this quaternions by the float components of another one .
 * @ param x The x ( imaginary ) component of the quaternion to divide with
 * @ param y The y ( imaginary ) component of the quaternion to divide with
 * @ param z The z ( imaginary ) component of the quaternion to divide with
 * @ param w The w ( real ) component of the quaternion to divide with
 * @ return The quotient of the two quaternions */
public Quaternionf div ( float x , float y , float z , float w ) { } }

implementation: final float d = x * x + y * y + z * z + w * w ; return new Quaternionf ( ( this . x * w - this . w * x - this . z * y + this . y * z ) / d , ( this . y * w + this . z * x - this . w * y - this . x * z ) / d , ( this . z * w - this . y * x + this . x * y - this . w * z ) / d , ( this . w * w + this . x * x + this . y * y + this . z * z ) / d ) ;


signature:
public class Quaternionf { /** * Returns the dot product of this quaternion with another one .
 * @ param q The quaternion to calculate the dot product with
 * @ return The dot product of the two quaternions */
public float dot ( Quaternionf q ) { } }

implementation: return dot ( q . x , q . y , q . z , q . w ) ;


signature:
public class Quaternionf { /** * Rotates a vector by this quaternion .
 * @ param v The vector to rotate
 * @ return The rotated vector */
public Vector3f rotate ( Vector3f v ) { } }

implementation: return rotate ( v . getX ( ) , v . getY ( ) , v . getZ ( ) ) ;


signature:
public class Quaternionf { /** * Returns the axis of rotation for this quaternion .
 * @ return The axis of rotation */
public Vector3f getAxis ( ) { } }

implementation: final float q = ( float ) Math . sqrt ( 1 - w * w ) ; return new Vector3f ( x / q , y / q , z / q ) ;


signature:
public class Quaternionf { /** * Returns the angles in radians around the x , y and z axes that correspond to the rotation represented by this quaternion .
 * @ return The angle in radians for each axis , stored in a vector , in the corresponding component */
public Vector3f getAxesAnglesRad ( ) { } }

implementation: final double roll ; final double pitch ; double yaw ; final double test = w * x - y * z ; if ( Math . abs ( test ) < 0.4999 ) { roll = TrigMath . atan2 ( 2 * ( w * z + x * y ) , 1 - 2 * ( x * x + z * z ) ) ; pitch = TrigMath . asin ( 2 * test ) ; yaw = TrigMath . atan2 ( 2 * ( w * y + z * x ) , 1 - 2 * ( x * x + y * y ) ) ; } else { final int sign = ( test < 0 ) ? - 1 : 1 ; roll = 0 ; pitch = sign * Math . PI / 2 ; yaw = - sign * 2 * TrigMath . atan2 ( z , w ) ; } return new Vector3f ( pitch , yaw , roll ) ;


signature:
public class Quaternionf { /** * Inverts the quaternion . < br > Inversion of a quaternion < code > a < / code > returns quaternion < code > a < sup > - 1 < / sup > = a ' / | a | < sup > 2 < / sup > < / code > where < code > a ' < / code > is { @ link # conjugate ( )
 * conjugation } of < code > a < / code > , and < code > | a | < sup > 2 < / sup > < / code > is squared length of < code > a < / code > . < br > For any quaternions < code > a , b , c < / code > , such that < code > a * b = c < / code > equations
 * < code > a < sup > - 1 < / sup > * c = b < / code > and < code > c * b < sup > - 1 < / sup > = a < / code > are true .
 * @ return the inverted quaternion */
@ Override public Quaternionf invert ( ) { } }

implementation: final float lengthSquared = lengthSquared ( ) ; if ( Math . abs ( lengthSquared ) < GenericMath . FLT_EPSILON ) { throw new ArithmeticException ( "Cannot invert a quaternion of length zero" ) ; } return conjugate ( ) . div ( lengthSquared ) ;


signature:
public class Quaternionf { /** * Converts this quaternion to a complex by extracting the rotation around
 * the axis and returning it as a rotation in the plane perpendicular to the
 * rotation axis .
 * @ return The rotation without the axis as a complex */
public Complexf toComplex ( ) { } }

implementation: final float w2 = w * w ; return new Complexf ( 2 * w2 - 1 , 2 * w * ( float ) Math . sqrt ( 1 - w2 ) ) ;


signature:
public class Quaternionf { /** * Creates a new quaternion from the float imaginary components .
 * < p > The { @ link # ZERO } constant is re - used when { @ code x } , { @ code y } , and { @ code z } are 0 . < / p >
 * @ param x The x ( imaginary ) component
 * @ param y The y ( imaginary ) component
 * @ param z The z ( imaginary ) component
 * @ return The quaternion created from the float imaginary components */
public static Quaternionf fromImaginary ( float x , float y , float z ) { } }

implementation: return x == 0 && y == 0 && z == 0 ? ZERO : new Quaternionf ( x , y , z , 0 ) ;


signature:
public class Quaternionf { /** * Creates a new quaternion from the float components .
 * < p > The { @ link # ZERO } constant is re - used when { @ code x } , { @ code y } , { @ code z } , and { @ code w } are 0 . < / p >
 * @ param x The x ( imaginary ) component
 * @ param y The y ( imaginary ) component
 * @ param z The z ( imaginary ) component
 * @ param w The w ( real ) component
 * @ return The quaternion created from the float components */
public static Quaternionf from ( float x , float y , float z , float w ) { } }

implementation: return x == 0 && y == 0 && z == 0 && w == 0 ? ZERO : new Quaternionf ( x , y , z , w ) ;


signature:
public class Quaternionf { /** * Creates a new quaternion from the float angles in degrees around the x , y and z axes .
 * @ param pitch The rotation around x
 * @ param yaw The rotation around y
 * @ param roll The rotation around z
 * @ return The quaternion defined by the rotations around the axes */
public static Quaternionf fromAxesAnglesDeg ( float pitch , float yaw , float roll ) { } }

implementation: return Quaternionf . fromAngleDegAxis ( yaw , Vector3f . UNIT_Y ) . mul ( Quaternionf . fromAngleDegAxis ( pitch , Vector3f . UNIT_X ) ) . mul ( Quaternionf . fromAngleDegAxis ( roll , Vector3f . UNIT_Z ) ) ;


signature:
public class Quaternionf { /** * Creates a new quaternion from the float angles in radians around the x , y and z axes .
 * @ param pitch The rotation around x
 * @ param yaw The rotation around y
 * @ param roll The rotation around z
 * @ return The quaternion defined by the rotations around the axes */
public static Quaternionf fromAxesAnglesRad ( float pitch , float yaw , float roll ) { } }

implementation: return Quaternionf . fromAngleRadAxis ( yaw , Vector3f . UNIT_Y ) . mul ( Quaternionf . fromAngleRadAxis ( pitch , Vector3f . UNIT_X ) ) . mul ( Quaternionf . fromAngleRadAxis ( roll , Vector3f . UNIT_Z ) ) ;


signature:
public class Quaternionf { /** * Creates a new quaternion from the angle - axis rotation defined from the first to the second vector .
 * @ param from The first vector
 * @ param to The second vector
 * @ return The quaternion defined by the angle - axis rotation between the vectors */
public static Quaternionf fromRotationTo ( Vector3f from , Vector3f to ) { } }

implementation: return Quaternionf . fromAngleRadAxis ( TrigMath . acos ( from . dot ( to ) / ( from . length ( ) * to . length ( ) ) ) , from . cross ( to ) ) ;


signature:
public class Quaternionf { /** * Creates a new quaternion from the rotation double angle in degrees around the axis vector .
 * @ param angle The rotation angle in degrees
 * @ param axis The axis of rotation
 * @ return The quaternion defined by the rotation around the axis */
public static Quaternionf fromAngleDegAxis ( double angle , Vector3f axis ) { } }

implementation: return fromAngleRadAxis ( Math . toRadians ( angle ) , axis ) ;


signature:
public class Quaternionf { /** * Creates a new quaternion from the rotation float angle in radians around the axis vector .
 * @ param angle The rotation angle in radians
 * @ param axis The axis of rotation
 * @ return The quaternion defined by the rotation around the axis */
public static Quaternionf fromAngleRadAxis ( float angle , Vector3f axis ) { } }

implementation: return fromAngleRadAxis ( angle , axis . getX ( ) , axis . getY ( ) , axis . getZ ( ) ) ;


signature:
public class Quaternionf { /** * Creates a new quaternion from the rotation double angle in radians around the axis vector double components .
 * @ param angle The rotation angle in radians
 * @ param x The x component of the axis vector
 * @ param y The y component of the axis vector
 * @ param z The z component of the axis vector
 * @ return The quaternion defined by the rotation around the axis */
public static Quaternionf fromAngleRadAxis ( double angle , double x , double y , double z ) { } }

implementation: return fromAngleRadAxis ( ( float ) angle , ( float ) x , ( float ) y , ( float ) z ) ;


signature:
public class Quaternionf { /** * Creates a new quaternion from the rotation float angle in radians around the axis vector float components .
 * @ param angle The rotation angle in radians
 * @ param x The x component of the axis vector
 * @ param y The y component of the axis vector
 * @ param z The z component of the axis vector
 * @ return The quaternion defined by the rotation around the axis */
public static Quaternionf fromAngleRadAxis ( float angle , float x , float y , float z ) { } }

implementation: final float halfAngle = angle / 2 ; final float q = TrigMath . sin ( halfAngle ) / ( float ) Math . sqrt ( x * x + y * y + z * z ) ; return new Quaternionf ( x * q , y * q , z * q , TrigMath . cos ( halfAngle ) ) ;


signature:
public class Quaternionf { /** * Creates a new quaternion from the rotation matrix . The matrix will be interpreted as a rotation matrix even if it is not .
 * @ param matrix The rotation matrix
 * @ return The quaternion defined by the rotation matrix */
public static Quaternionf fromRotationMatrix ( Matrix3f matrix ) { } }

implementation: final float trace = matrix . trace ( ) ; if ( trace < 0 ) { if ( matrix . get ( 1 , 1 ) > matrix . get ( 0 , 0 ) ) { if ( matrix . get ( 2 , 2 ) > matrix . get ( 1 , 1 ) ) { final float r = ( float ) Math . sqrt ( matrix . get ( 2 , 2 ) - matrix . get ( 0 , 0 ) - matrix . get ( 1 , 1 ) + 1 ) ; final float s = 0.5f / r ; return new Quaternionf ( ( matrix . get ( 2 , 0 ) + matrix . get ( 0 , 2 ) ) * s , ( matrix . get ( 1 , 2 ) + matrix . get ( 2 , 1 ) ) * s , 0.5f * r , ( matrix . get ( 1 , 0 ) - matrix . get ( 0 , 1 ) ) * s ) ; } else { final float r = ( float ) Math . sqrt ( matrix . get ( 1 , 1 ) - matrix . get ( 2 , 2 ) - matrix . get ( 0 , 0 ) + 1 ) ; final float s = 0.5f / r ; return new Quaternionf ( ( matrix . get ( 0 , 1 ) + matrix . get ( 1 , 0 ) ) * s , 0.5f * r , ( matrix . get ( 1 , 2 ) + matrix . get ( 2 , 1 ) ) * s , ( matrix . get ( 0 , 2 ) - matrix . get ( 2 , 0 ) ) * s ) ; } } else if ( matrix . get ( 2 , 2 ) > matrix . get ( 0 , 0 ) ) { final float r = ( float ) Math . sqrt ( matrix . get ( 2 , 2 ) - matrix . get ( 0 , 0 ) - matrix . get ( 1 , 1 ) + 1 ) ; final float s = 0.5f / r ; return new Quaternionf ( ( matrix . get ( 2 , 0 ) + matrix . get ( 0 , 2 ) ) * s , ( matrix . get ( 1 , 2 ) + matrix . get ( 2 , 1 ) ) * s , 0.5f * r , ( matrix . get ( 1 , 0 ) - matrix . get ( 0 , 1 ) ) * s ) ; } else { final float r = ( float ) Math . sqrt ( matrix . get ( 0 , 0 ) - matrix . get ( 1 , 1 ) - matrix . get ( 2 , 2 ) + 1 ) ; final float s = 0.5f / r ; return new Quaternionf ( 0.5f * r , ( matrix . get ( 0 , 1 ) + matrix . get ( 1 , 0 ) ) * s , ( matrix . get ( 2 , 0 ) - matrix . get ( 0 , 2 ) ) * s , ( matrix . get ( 2 , 1 ) - matrix . get ( 1 , 2 ) ) * s ) ; } } else { final float r = ( float ) Math . sqrt ( trace + 1 ) ; final float s = 0.5f / r ; return new Quaternionf ( ( matrix . get ( 2 , 1 ) - matrix . get ( 1 , 2 ) ) * s , ( matrix . get ( 0 , 2 ) - matrix . get ( 2 , 0 ) ) * s , ( matrix . get ( 1 , 0 ) - matrix . get ( 0 , 1 ) ) * s , 0.5f * r ) ; }


signature:
public class MatrixNf { /** * Creates a perspective projection matrix with the given ( x ) FOV , aspect , near and far planes
 * @ param size The size of the matrix , minimum of 4
 * @ param fov The field of view in the x direction
 * @ param aspect The aspect ratio , usually width / height
 * @ param near The near plane , cannot be 0
 * @ param far the far plane , zFar cannot equal zNear
 * @ return A perspective projection matrix built from the given values */
public static MatrixNf createPerspective ( int size , double fov , double aspect , double near , double far ) { } }

implementation: return createPerspective ( size , ( float ) fov , ( float ) aspect , ( float ) near , ( float ) far ) ;


signature:
public class Complexd { /** * Multiplies the double components of another complex with this one .
 * @ param x The x ( real ) component of the complex to multiply with
 * @ param y The y ( imaginary ) component of the complex to multiply with
 * @ return A new complex , which is the product of both */
public Complexd mul ( double x , double y ) { } }

implementation: return new Complexd ( this . x * x - this . y * y , this . x * y + this . y * x ) ;


signature:
public class Complexd { /** * Divides this complex by the double components of another one .
 * @ param x The x ( real ) component of the complex to divide with
 * @ param y The y ( imaginary ) component of the complex to divide with
 * @ return The quotient of the two complexes */
public Complexd div ( double x , double y ) { } }

implementation: final double d = x * x + y * y ; return new Complexd ( ( this . x * x + this . y * y ) / d , ( this . y * x - this . x * y ) / d ) ;


signature:
public class Complexd { /** * Rotates the double components of a vector by this complex .
 * @ param x The x component of the vector
 * @ param y The y component of the vector
 * @ return The rotated vector */
public Vector2d rotate ( double x , double y ) { } }

implementation: final double length = length ( ) ; if ( Math . abs ( length ) < GenericMath . DBL_EPSILON ) { throw new ArithmeticException ( "Cannot rotate by the zero complex" ) ; } final double nx = this . x / length ; final double ny = this . y / length ; return new Vector2d ( x * nx - y * ny , y * nx + x * ny ) ;


signature:
public class Complexd { /** * Returns the inverse of this complex . < br > Inversion of a complex < code > a < / code > returns complex < code > a < sup > - 1 < / sup > = a ' / | a | < sup > 2 < / sup > < / code > where < code > a ' < / code > is { @ link # conjugate ( )
 * conjugation } of < code > a < / code > , and < code > | a | < sup > 2 < / sup > < / code > is squared length of < code > a < / code > . < br > For any complexes < code > a , b , c < / code > , such that < code > a * b = c < / code > equations
 * < code > a < sup > - 1 < / sup > * c = b < / code > and < code > c * b < sup > - 1 < / sup > = a < / code > are true .
 * @ return A new complex , which is the inverse of this one */
@ Override public Complexd invert ( ) { } }

implementation: final double lengthSquared = lengthSquared ( ) ; if ( Math . abs ( lengthSquared ) < GenericMath . DBL_EPSILON ) { throw new ArithmeticException ( "Cannot invert a complex of length zero" ) ; } return conjugate ( ) . div ( lengthSquared ) ;


signature:
public class Complexd { /** * Converts this complex to a quaternion by
 * using the provided vector as a rotation axis .
 * @ param axis The rotation axis
 * @ return A quaternion of this rotation around the given axis */
public Quaterniond toQuaternion ( Vector3d axis ) { } }

implementation: return toQuaternion ( axis . getX ( ) , axis . getY ( ) , axis . getZ ( ) ) ;


signature:
public class Complexd { /** * Converts this complex to a quaternion by
 * using the provided double components vector
 * as a rotation axis .
 * @ param x The x component of the axis vector
 * @ param y The y component of the axis vector
 * @ param z The z component of the axis vector
 * @ return A quaternion of this rotation around the given axis */
public Quaterniond toQuaternion ( double x , double y , double z ) { } }

implementation: return Quaterniond . fromAngleRadAxis ( getAngleRad ( ) , x , y , z ) ;


signature:
public class Complexd { /** * Creates a new complex from the double components .
 * < p > The { @ link # ZERO } constant is re - used when both { @ code x } and { @ code z } are 0 . < / p >
 * @ param x The x ( real ) component
 * @ param y The y ( imaginary ) component
 * @ return The complex created from the double components */
public static Complexd from ( double x , double y ) { } }

implementation: return x == 0 && y == 0 ? ZERO : new Complexd ( x , y ) ;


signature:
public class Complexd { /** * Creates a new complex from the angle defined from the first to the second vector .
 * @ param from The first vector
 * @ param to The second vector
 * @ return The complex defined by the angle between the vectors */
public static Complexd fromRotationTo ( Vector2d from , Vector2d to ) { } }

implementation: return fromAngleRad ( TrigMath . acos ( from . dot ( to ) / ( from . length ( ) * to . length ( ) ) ) ) ;


signature:
public class Complexd { /** * Creates a new complex from the double angle in radians .
 * @ param angle The angle in radians
 * @ return The complex defined by the angle */
public static Complexd fromAngleRad ( double angle ) { } }

implementation: return new Complexd ( TrigMath . cos ( angle ) , TrigMath . sin ( angle ) ) ;


signature:
public class ScalableLayout { /** * move childView inside ScalableLayout
 * @ param pChildView view to move . should be child of ScaleLayout
 * @ param pScale _ Left
 * @ param pScale _ Top */
public void moveChildView ( View pChildView , float pScale_Left , float pScale_Top ) { } }

implementation: ScalableLayout . LayoutParams lSLLP = getChildLayoutParams ( pChildView ) ; lSLLP . mScale_Left = pScale_Left ; lSLLP . mScale_Top = pScale_Top ; postInvalidate ( ) ;


signature:
public class ScalableLayout { /** * move and resize childView inside ScalableLayout
 * @ param pChildView view to move . should be child of ScaleLayout
 * @ param pScale _ Left
 * @ param pScale _ Top
 * @ param pScale _ Width
 * @ param pScale _ Height */
public void moveChildView ( View pChildView , float pScale_Left , float pScale_Top , float pScale_Width , float pScale_Height ) { } }

implementation: ScalableLayout . LayoutParams lSLLP = getChildLayoutParams ( pChildView ) ; lSLLP . mScale_Left = pScale_Left ; lSLLP . mScale_Top = pScale_Top ; lSLLP . mScale_Width = pScale_Width ; lSLLP . mScale_Height = pScale_Height ; postInvalidate ( ) ;


signature:
public class ScalableLayout { /** * adds new TextView with ( TextSize , Left , Top , Width , Height ) parameters
 * DuplicateState is false by default .
 * @ param pText
 * @ param pScale _ TextSize
 * @ param pScale _ Left
 * @ param pScale _ Top
 * @ param pScale _ Width
 * @ param pScale _ Height
 * @ return created TextView instance */
public TextView addNewTextView ( String pText , float pScale_TextSize , float pScale_Left , float pScale_Top , float pScale_Width , float pScale_Height ) { } }

implementation: return addNewTextView ( pText , pScale_TextSize , pScale_Left , pScale_Top , pScale_Width , pScale_Height , false ) ;


signature:
public class ScalableLayout { /** * adds new TextView with ( TextSize , Left , Top , Width , Height , duplicateState ) parameters
 * @ param pText
 * @ param pScale _ TextSize
 * @ param pScale _ Left
 * @ param pScale _ Top
 * @ param pScale _ Width
 * @ param pScale _ Height
 * @ param pDuplicateState
 * @ return created TextView instance */
public TextView addNewTextView ( String pText , float pScale_TextSize , float pScale_Left , float pScale_Top , float pScale_Width , float pScale_Height , boolean pDuplicateState ) { } }

implementation: TextView ret = new TextView ( getContext ( ) ) ; addView ( ret , pScale_Left , pScale_Top , pScale_Width , pScale_Height ) ; setScale_TextSize ( ret , pScale_TextSize ) ; ret . setText ( pText ) ; ret . setGravity ( Gravity . CENTER ) ; ret . setTextColor ( Color . BLACK ) ; ret . setDuplicateParentStateEnabled ( pDuplicateState ) ; return ret ;


signature:
public class ScalableLayout { /** * adds new EditText with ( TextSize , Left , Top , Width , Height ) parameters
 * @ param pScale _ TextSize
 * @ param pScale _ Left
 * @ param pScale _ Top
 * @ param pScale _ Width
 * @ param pScale _ Height
 * @ return created EditText instance */
public EditText addNewEditText ( float pScale_TextSize , float pScale_Left , float pScale_Top , float pScale_Width , float pScale_Height ) { } }

implementation: EditText ret = new EditText ( getContext ( ) ) ; addView ( ret , pScale_Left , pScale_Top , pScale_Width , pScale_Height ) ; setScale_TextSize ( ret , pScale_TextSize ) ; ret . setGravity ( Gravity . CENTER ) ; ret . setTextColor ( Color . BLACK ) ; return ret ;


signature:
public class ScalableLayout { /** * adds new ImageView with ( Left , Top , Width , Height ) parameters
 * Drawable is null by default .
 * DuplicateState is false by default .
 * @ param pScale _ Left
 * @ param pScale _ Top
 * @ param pScale _ Width
 * @ param pScale _ Height
 * @ return created ImageView instance */
public ImageView addNewImageView ( float pScale_Left , float pScale_Top , float pScale_Width , float pScale_Height ) { } }

implementation: return addNewImageView ( ( Drawable ) null , pScale_Left , pScale_Top , pScale_Width , pScale_Height , false ) ;


signature:
public class ScalableLayout { /** * adds new ImageView with ( Bitmap , Left , Top , Width , Height ) parameters
 * sets Image of ImageView with Bitmap parameter
 * DuplicateState is false by default .
 * @ param pBitmap
 * @ param pScale _ Left
 * @ param pScale _ Top
 * @ param pScale _ Width
 * @ param pScale _ Height
 * @ return created ImageView instance */
public ImageView addNewImageView ( Bitmap pBitmap , float pScale_Left , float pScale_Top , float pScale_Width , float pScale_Height ) { } }

implementation: BitmapDrawable bm = new BitmapDrawable ( getResources ( ) , pBitmap ) ; return addNewImageView ( bm , pScale_Left , pScale_Top , pScale_Width , pScale_Height , false ) ;


signature:
public class ScalableLayout { /** * adds new ImageView with ( ResourceID , Left , Top , Width , Height ) parameters
 * sets Image of ImageView with ResourceID parameter
 * DuplicateState is false by default .
 * @ param pResID
 * @ param pScale _ Left
 * @ param pScale _ Top
 * @ param pScale _ Width
 * @ param pScale _ Height
 * @ return created ImageView instance */
public ImageView addNewImageView ( int pResID , float pScale_Left , float pScale_Top , float pScale_Width , float pScale_Height ) { } }

implementation: return addNewImageView ( pResID , pScale_Left , pScale_Top , pScale_Width , pScale_Height , false ) ;


signature:
public class ScalableLayout { /** * adds new ImageView with ( ResourceID , Left , Top , Width , Height , DuplicateState ) parameters
 * sets Image of ImageView with ResourceID parameter
 * @ param pResID
 * @ param pScale _ Left
 * @ param pScale _ Top
 * @ param pScale _ Width
 * @ param pScale _ Height
 * @ param pDuplicateState
 * @ return created ImageView instance */
public ImageView addNewImageView ( int pResID , float pScale_Left , float pScale_Top , float pScale_Width , float pScale_Height , boolean pDuplicateState ) { } }

implementation: BitmapFactory . Options options = new BitmapFactory . Options ( ) ; options . inPreferredConfig = Bitmap . Config . ARGB_8888 ; return addNewImageView ( new BitmapDrawable ( getResources ( ) , BitmapFactory . decodeResource ( getResources ( ) , pResID , options ) ) , pScale_Left , pScale_Top , pScale_Width , pScale_Height , pDuplicateState ) ;


signature:
public class ScalableLayout { /** * adds new ImageView with ( Drawable , Left , Top , Width , Height , DuplicateState ) parameters
 * sets Image of ImageView with Drawable parameter
 * @ param drawable
 * @ param pScale _ Left
 * @ param pScale _ Top
 * @ param pScale _ Width
 * @ param pScale _ Height
 * @ param pDuplicateState
 * @ return */
public ImageView addNewImageView ( Drawable drawable , float pScale_Left , float pScale_Top , float pScale_Width , float pScale_Height , boolean pDuplicateState ) { } }

implementation: ImageView lNewImageView = new ImageView ( getContext ( ) ) ; lNewImageView . setImageDrawable ( drawable ) ; lNewImageView . setScaleType ( ScaleType . FIT_XY ) ; lNewImageView . setDuplicateParentStateEnabled ( pDuplicateState ) ; addView ( lNewImageView , pScale_Left , pScale_Top , pScale_Width , pScale_Height ) ; return lNewImageView ;


signature: public class MainActivity { @ Override public boolean onCreateOptionsMenu ( Menu menu ) { } }

implementation:
// Inflate the menu ; this adds items to the action bar if it is present .
getMenuInflater ( ) . inflate ( com . ssomai . android . sample_scalablelayout . R . menu . menu_main , menu ) ; return true ;


signature:
public class Bypass { /** * you have ? " . */
private CharSequence recurseElement ( Element element , int indexWithinParent , int numberOfSiblings , ImageGetter imageGetter ) { } }

implementation:
Type type = element . getType ( ) ; boolean isOrderedList = false ; if ( type == Type . LIST ) { String flagsStr = element . getAttribute ( "flags" ) ; if ( flagsStr != null ) { int flags = Integer . parseInt ( flagsStr ) ; isOrderedList = ( flags & Element . F_LIST_ORDERED ) != 0 ; if ( isOrderedList ) { mOrderedListNumber . put ( element , 1 ) ; } } } int size = element . size ( ) ; CharSequence [ ] spans = new CharSequence [ size ] ; for ( int i = 0 ; i < size ; i ++ ) { spans [ i ] = recurseElement ( element . children [ i ] , i , size , imageGetter ) ; } // Clean up after we ' re done
if ( isOrderedList ) { mOrderedListNumber . remove ( this ) ; } CharSequence concat = TextUtils . concat ( spans ) ; SpannableStringBuilder builder = new ReverseSpannableStringBuilder ( ) ; String text = element . getText ( ) ; if ( element . size ( ) == 0 && element . getParent ( ) != null && element . getParent ( ) . getType ( ) != Type . BLOCK_CODE ) { text = text . replace ( '\n' , ' ' ) ; } // Retrieve the image now so we know whether we ' re going to have something to display later
// If we don ' t , then show the alt text instead ( if available ) .
Drawable imageDrawable = null ; if ( type == Type . IMAGE && imageGetter != null && ! TextUtils . isEmpty ( element . getAttribute ( "link" ) ) ) { imageDrawable = imageGetter . getDrawable ( element . getAttribute ( "link" ) ) ; } switch ( type ) { case LIST : if ( element . getParent ( ) != null && element . getParent ( ) . getType ( ) == Type . LIST_ITEM ) { builder . append ( "\n" ) ; } break ; case LINEBREAK : builder . append ( "\n" ) ; break ; case LIST_ITEM : builder . append ( " " ) ; if ( mOrderedListNumber . containsKey ( element . getParent ( ) ) ) { int number = mOrderedListNumber . get ( element . getParent ( ) ) ; builder . append ( Integer . toString ( number ) + "." ) ; mOrderedListNumber . put ( element . getParent ( ) , number + 1 ) ; } else { builder . append ( mOptions . mUnorderedListItem ) ; } builder . append ( "  " ) ; break ; case AUTOLINK : builder . append ( element . getAttribute ( "link" ) ) ; break ; case HRULE : // This ultimately gets drawn over by the line span , but
// we need something here or the span isn ' t even drawn .
builder . append ( "-" ) ; break ; case IMAGE : // Display alt text ( or title text ) if there is no image
if ( imageDrawable == null ) { String show = element . getAttribute ( "alt" ) ; if ( TextUtils . isEmpty ( show ) ) { show = element . getAttribute ( "title" ) ; } if ( ! TextUtils . isEmpty ( show ) ) { show = "[" + show + "]" ; builder . append ( show ) ; } } else { // Character to be replaced
builder . append ( "\uFFFC" ) ; } break ; } builder . append ( text ) ; builder . append ( concat ) ; // Don ' t auto - append whitespace after last item in document . The ' numberOfSiblings '
// is the number of children the parent of the current element has ( including the
// element itself ) , hence subtracting a number from that count gives us the index
// of the last child within the parent .
if ( element . getParent ( ) != null || indexWithinParent < ( numberOfSiblings - 1 ) ) { if ( type == Type . LIST_ITEM ) { if ( element . size ( ) == 0 || ! element . children [ element . size ( ) - 1 ] . isBlockElement ( ) ) { builder . append ( "\n" ) ; } } else if ( element . isBlockElement ( ) && type != Type . BLOCK_QUOTE ) { if ( type == Type . LIST ) { // If this is a nested list , don ' t include newlines
if ( element . getParent ( ) == null || element . getParent ( ) . getType ( ) != Type . LIST_ITEM ) { builder . append ( "\n" ) ; } } else if ( element . getParent ( ) != null && element . getParent ( ) . getType ( ) == Type . LIST_ITEM ) { // List items should never double - space their entries
builder . append ( "\n" ) ; } else { builder . append ( "\n\n" ) ; } } } switch ( type ) { case HEADER : String levelStr = element . getAttribute ( "level" ) ; int level = Integer . parseInt ( levelStr ) ; setSpan ( builder , new RelativeSizeSpan ( mOptions . mHeaderSizes [ level - 1 ] ) ) ; setSpan ( builder , new StyleSpan ( Typeface . BOLD ) ) ; break ; case LIST : setBlockSpan ( builder , new LeadingMarginSpan . Standard ( mListItemIndent ) ) ; break ; case EMPHASIS : setSpan ( builder , new StyleSpan ( Typeface . ITALIC ) ) ; break ; case DOUBLE_EMPHASIS : setSpan ( builder , new StyleSpan ( Typeface . BOLD ) ) ; break ; case TRIPLE_EMPHASIS : setSpan ( builder , new StyleSpan ( Typeface . BOLD_ITALIC ) ) ; break ; case BLOCK_CODE : setSpan ( builder , new LeadingMarginSpan . Standard ( mCodeBlockIndent ) ) ; setSpan ( builder , new TypefaceSpan ( "monospace" ) ) ; break ; case CODE_SPAN : setSpan ( builder , new TypefaceSpan ( "monospace" ) ) ; break ; case LINK : case AUTOLINK : String link = element . getAttribute ( "link" ) ; if ( ! TextUtils . isEmpty ( link ) && Patterns . EMAIL_ADDRESS . matcher ( link ) . matches ( ) ) { link = "mailto:" + link ; } setSpan ( builder , new URLSpan ( link ) ) ; break ; case BLOCK_QUOTE : // We add two leading margin spans so that when the order is reversed ,
// the QuoteSpan will always be in the same spot .
setBlockSpan ( builder , new LeadingMarginSpan . Standard ( mBlockQuoteIndent ) ) ; setBlockSpan ( builder , new QuoteSpan ( mOptions . mBlockQuoteColor ) ) ; setBlockSpan ( builder , new LeadingMarginSpan . Standard ( mBlockQuoteIndent ) ) ; setBlockSpan ( builder , new StyleSpan ( Typeface . ITALIC ) ) ; break ; case STRIKETHROUGH : setSpan ( builder , new StrikethroughSpan ( ) ) ; break ; case HRULE : setSpan ( builder , new HorizontalLineSpan ( mOptions . mHruleColor , mHruleSize , mHruleTopBottomPadding ) ) ; break ; case IMAGE : if ( imageDrawable != null ) { setSpan ( builder , new ImageSpan ( imageDrawable ) ) ; } break ; } return builder ;


signature:
public class Bypass { /** * These have trailing newlines that we want to avoid spanning */
private static void setBlockSpan ( SpannableStringBuilder builder , Object what ) { } }

implementation: int length = Math . max ( 0 , builder . length ( ) - 1 ) ; builder . setSpan ( what , 0 , length , Spannable . SPAN_EXCLUSIVE_EXCLUSIVE ) ;


signature:
public class ConstraintFormulaSet { /** * Takes a compatibility assertion about an expression or type , called a constraint formula , and reduces it to a
 * set of bounds on inference variables . Often , a constraint formula reduces to other constraint formulas ,
 * which must be recursively reduced . A procedure is followed to identify these additional constraint formulas and ,
 * ultimately , to express via a bound set the conditions under which the choices for inferred types would render
 * each constraint formula true . */
public BoundSet reduce ( TypeSolver typeSolver ) { } }

implementation: List < ConstraintFormula > constraints = new LinkedList < > ( constraintFormulas ) ; BoundSet boundSet = BoundSet . empty ( ) ; while ( constraints . size ( ) > 0 ) { ConstraintFormula constraintFormula = constraints . remove ( 0 ) ; ConstraintFormula . ReductionResult reductionResult = constraintFormula . reduce ( boundSet ) ; constraints . addAll ( reductionResult . getConstraintFormulas ( ) ) ; boundSet . incorporate ( reductionResult . getBoundSet ( ) , typeSolver ) ; } return boundSet ;


signature:
public class ReferenceTypeImpl { /** * This method checks if ThisType t = new OtherType ( ) would compile . */
@ Override public boolean isAssignableBy ( ResolvedType other ) { } }

implementation:
if ( other instanceof NullType ) { return ! this . isPrimitive ( ) ; } // everything is assignable to Object except void
if ( ! other . isVoid ( ) && this . getQualifiedName ( ) . equals ( Object . class . getCanonicalName ( ) ) ) { return true ; } // consider boxing
if ( other . isPrimitive ( ) ) { if ( this . getQualifiedName ( ) . equals ( Object . class . getCanonicalName ( ) ) ) { return true ; } else { // Check if ' other ' can be boxed to match this type
if ( isCorrespondingBoxingType ( other . describe ( ) ) ) return true ; // Resolve the boxed type and check if it can be assigned via widening reference conversion
SymbolReference < ResolvedReferenceTypeDeclaration > type = typeSolver . tryToSolveType ( other . asPrimitive ( ) . getBoxTypeQName ( ) ) ; return type . getCorrespondingDeclaration ( ) . canBeAssignedTo ( super . typeDeclaration ) ; } } if ( other instanceof LambdaArgumentTypePlaceholder ) { return this . getTypeDeclaration ( ) . hasAnnotation ( FunctionalInterface . class . getCanonicalName ( ) ) ; } else if ( other instanceof ReferenceTypeImpl ) { ReferenceTypeImpl otherRef = ( ReferenceTypeImpl ) other ; if ( compareConsideringTypeParameters ( otherRef ) ) { return true ; } for ( ResolvedReferenceType otherAncestor : otherRef . getAllAncestors ( ) ) { if ( compareConsideringTypeParameters ( otherAncestor ) ) { return true ; } } return false ; } else if ( other . isTypeVariable ( ) ) { for ( ResolvedTypeParameterDeclaration . Bound bound : other . asTypeVariable ( ) . asTypeParameter ( ) . getBounds ( ) ) { if ( bound . isExtends ( ) ) { if ( this . isAssignableBy ( bound . getType ( ) ) ) { return true ; } } } return false ; } else if ( other . isConstraint ( ) ) { return isAssignableBy ( other . asConstraintType ( ) . getBound ( ) ) ; } else if ( other . isWildcard ( ) ) { if ( this . getQualifiedName ( ) . equals ( Object . class . getCanonicalName ( ) ) ) { return true ; } else if ( other . asWildcard ( ) . isExtends ( ) ) { return isAssignableBy ( other . asWildcard ( ) . getBoundedType ( ) ) ; } else { return false ; } } else { return false ; }


signature:
public class ReferenceTypeImpl { /** * Execute a transformation on all the type parameters of this element . */
@ Override public ResolvedType transformTypeParameters ( ResolvedTypeTransformer transformer ) { } }

implementation:
ResolvedType result = this ; int i = 0 ; for ( ResolvedType tp : this . typeParametersValues ( ) ) { ResolvedType transformedTp = transformer . transform ( tp ) ; // Identity comparison on purpose
if ( transformedTp != tp ) { List < ResolvedType > typeParametersCorrected = result . asReferenceType ( ) . typeParametersValues ( ) ; typeParametersCorrected . set ( i , transformedTp ) ; result = create ( typeDeclaration , typeParametersCorrected ) ; } i ++ ; } return result ;


signature:
public class SymbolReference { /** * Create a solve reference to the given symbol . */
public static < S extends ResolvedDeclaration , S2 extends S > SymbolReference < S > solved ( S2 symbolDeclaration ) { } }

implementation: return new SymbolReference < S > ( Optional . of ( symbolDeclaration ) ) ;


signature:
public class SymbolReference { /** * Create an unsolved reference specifying the type of the value expected . */
public static < S extends ResolvedDeclaration , S2 extends S > SymbolReference < S > unsolved ( Class < S2 > clazz ) { } }

implementation: return new SymbolReference < > ( Optional . empty ( ) ) ;


signature:
public class TypeHelper { /** * The term proper type excludes such " types " that mention inference variables . */
public static boolean isProperType ( ResolvedType type ) { } }

implementation:
if ( type instanceof InferenceVariable ) { return false ; } if ( type instanceof ResolvedReferenceType ) { ResolvedReferenceType referenceType = ( ResolvedReferenceType ) type ; return referenceType . typeParametersValues ( ) . stream ( ) . allMatch ( it -> isProperType ( it ) ) ; } if ( type instanceof ResolvedWildcard ) { ResolvedWildcard wildcard = ( ResolvedWildcard ) type ; if ( wildcard . isBounded ( ) ) { return isProperType ( wildcard . getBoundedType ( ) ) ; } else { return true ; } } if ( type . isPrimitive ( ) ) { return true ; } if ( type . isTypeVariable ( ) ) { // FIXME I am not sure . . .
return false ; } if ( type . isArray ( ) ) { return isProperType ( type . asArrayType ( ) . getComponentType ( ) ) ; } throw new UnsupportedOperationException ( type . toString ( ) ) ;


signature:
public class TypeHelper { /** * see https : / / docs . oracle . com / javase / specs / jls / se8 / html / jls - 5 . html # jls - 5.3
 * @ param expression
 * @ param t
 * @ return */
public static boolean isCompatibleInALooseInvocationContext ( TypeSolver typeSolver , Expression expression , ResolvedType t ) { } }

implementation:
// throw new UnsupportedOperationException ( " Unable to determine if " + expression + " is compatible in a loose invocation context with type " + t ) ;
return isCompatibleInALooseInvocationContext ( JavaParserFacade . get ( typeSolver ) . getType ( expression ) , t ) ;