com.mhuss.AstroLib
Class MathOps
- java.lang.Object
-
- com.mhuss.AstroLib.MathOps
-
public class MathOps extends java.lang.ObjectMathOps contains some useful trig, vector and matrix operations.Based on C code by Bill Gray (www.projectpluto.com)
-
-
Field Summary
Fields Modifier and Type Field and Description static intVECTOR_SIZE
-
Constructor Summary
Constructors Constructor and Description MathOps()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static doubleacose(double arg)Calculates the arc cosine, but limits the input to the range ( -1.0 < rad < +1.0 ).static doubleasine(double arg)Calculates the arc sine, but limits the input to the range ( -1.0 < rad < +1.0 ).static voidcartesianToPolar(double[] cartVect, double[] polarCoord)static voidpolarToCartesian(double[] vectC, double[] vectP)Convert polar coordinates with radius to Cartesian coordinates added by w.static voidpolarToCartesian(double[] vect, double lon, double lat, double radius)Convert polar coordinates with radius to Cartesian coordinates added by w.static voidrotateVector(double[] v, double angle, int axis)Rotate a vector along the specified axis.static voidsetIdentityMatrix(double[] matrix)Initializes a matrix to base (identity) values.
-
-
-
Field Detail
-
VECTOR_SIZE
public static final int VECTOR_SIZE
- See Also:
- Constant Field Values
-
-
Method Detail
-
acose
public static double acose(double arg)
Calculates the arc cosine, but limits the input to the range ( -1.0 < rad < +1.0 ).
This avoids overflow errors. If the input is <= -1.0 radians, Math.PI is returned. If the input is >= 1.0 radians, 0 is returned.- Parameters:
arg- The angle in radians- Returns:
- The arc cosine, limited to the range 0 to Pi.
-
asine
public static double asine(double arg)
Calculates the arc sine, but limits the input to the range ( -1.0 < rad < +1.0 ).
This avoids overflow errors. If the input is less than -1 (radian), -PI/2 is returned. If the input is greater than 1 (radian), +PI/2 is returned.- Parameters:
arg- The angle in radians- Returns:
- The arc sine, limited to the range -Pi/2 0 to Pi/2.
-
setIdentityMatrix
public static void setIdentityMatrix(double[] matrix)
Initializes a matrix to base (identity) values. The matrix is set as follows: [1][0][0] [0][1][0] [0][0][1]- Parameters:
matrix- The matrix to initialize
-
rotateVector
public static void rotateVector(double[] v, double angle, int axis)Rotate a vector along the specified axis.- Parameters:
v- The vector to rotateangle- The angle to useaxis- The axis along which to rotate
-
polarToCartesian
public static void polarToCartesian(double[] vect, double lon, double lat, double radius)Convert polar coordinates with radius to Cartesian coordinates added by w. Strickling- Parameters:
vect- Vector to hold the Cartesian coordinateslon- Polar longitudelat- Polar latitude
-
polarToCartesian
public static void polarToCartesian(double[] vectC, double[] vectP)Convert polar coordinates with radius to Cartesian coordinates added by w. Strickling- Parameters:
vectC- Vector to hold the Cartesian coordinatesvectP- Vector to hold the Polar coordinates
-
cartesianToPolar
public static void cartesianToPolar(double[] cartVect, double[] polarCoord)
-
-
DMelt 3.0 © DataMelt by jWork.ORG