driver.ted.utilities
Class T_Utilities

java.lang.Object
  extended by driver.ted.utilities.T_Utilities

public class T_Utilities
extends java.lang.Object

Title: T_Utilities
Description: This class provides static utility functions.
Copyright: (c) 2002 - 2006
Change History:

Version:
1.1
Author:
Ted Driver

Field Summary
static double AsToRad
          Constant value to convert arcseconds to radians.
static double C
          Constant value for the Speed of Light c.
static double DtR
          Constant Value for the degrees to Radians conversion factor.
static double EarthEccentricity
          Constant value for the Earth's eccentricity.
static double EarthEquatorialRadius
          Constant Value for the Earth Equatorial Radius.
static double L1
          Constant value for the GPS L1 Frequency.
static double L2
          Constant Value for the GPS L2 Frequency.
static double PI
          Constant Value for Pi to 24 decimal places.
 
Constructor Summary
T_Utilities()
           
 
Method Summary
static java.lang.String decimalToDMS(double value, int precision)
          Function to return a string in Degree:Minute:Second format, provided a decimal value.
static java.lang.String decimalToDMSDIRH(double value, int precision)
          Utility to convert signed longitude degree.decimal values to DMS strings with directions added.
static java.lang.String decimalToDMSDIRV(double value, int precision)
          Utility to convert signed latitude degree.decimal values to DMS strings with directions added.
static java.lang.String decimalToRAHMS(double value, int precision)
          Public function to return a string to use in the format hh mm ss.s provided a double and an int precision.
static java.lang.String decimalToTimeHMS(double value, int precision)
          Public function to return a string to use in the format hh:mm:ss provided a double and an int precision.
static double getDecimalOfDouble(double a)
          This function gets all numbers to the right of the decimal of the double provided, including sign.
static int getIntOfDouble(double value)
          This function casts the double to an int, effectively returning just the integer portion of the double value.
static java.lang.String getPrecisionString(int leading, int precision)
          Public function to return a string to use in the DecimalFormat constructor, provided an integer.
static double normalize(double min, double max, double x)
          Static Public function to bound a number between a min and max value, using a default precision of 15.
static double normalize(double min, double max, double x, int precision)
          Static Public function to bound a number between a min and max value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

C

public static final double C
Constant value for the Speed of Light c. c = 299792458 m/s

See Also:
Constant Field Values

L1

public static final double L1
Constant value for the GPS L1 Frequency. L1 = 1575.42 MHz

See Also:
Constant Field Values

L2

public static final double L2
Constant Value for the GPS L2 Frequency. L2 = 1227.6 MHz

See Also:
Constant Field Values

PI

public static final double PI
Constant Value for Pi to 24 decimal places. Pi = 3.141592653589793238462643

See Also:
Constant Field Values

DtR

public static final double DtR
Constant Value for the degrees to Radians conversion factor. DtR = PI/180.0

See Also:
Constant Field Values

EarthEquatorialRadius

public static final double EarthEquatorialRadius
Constant Value for the Earth Equatorial Radius. EarthEquatorialRadius = 6378137.0 meters

See Also:
Constant Field Values

EarthEccentricity

public static final double EarthEccentricity
Constant value for the Earth's eccentricity. EarthEccentricity = 0.0818191908426156, no units

See Also:
Constant Field Values

AsToRad

public static double AsToRad
Constant value to convert arcseconds to radians. Use the inverse of this number to convert from radians to arcseconds AsToRad = 4.848136812e-6

Constructor Detail

T_Utilities

public T_Utilities()
Method Detail

normalize

public static double normalize(double min,
                               double max,
                               double x,
                               int precision)
Static Public function to bound a number between a min and max value. Example 1: to convert 270 degrees to the range -180 to 180 degrees

normalize(-180, 180, 270, 15)

returns -90.0 Example 2 to convert a decimal to its fractional value

normalize(0,1,23.789456,6)

returns 0.789456

Parameters:
min - The minimum value the number can have
max - The maximum value the number can have
x - The value to bound
precision - The precision of the returned value
Returns:
The value bounded between min and max

normalize

public static double normalize(double min,
                               double max,
                               double x)
Static Public function to bound a number between a min and max value, using a default precision of 15. Example 1: to convert 270 degrees to the range -180 to 180 degrees

normalize(-180, 180, 270)

P> returns -90.0 Example 2 to convert a decimal to its fractional value

normalize(0,1,23.789456)

returns 0.789456000000001

Parameters:
min - The minimum value the number can have
max - The maximum value the number can have
x - The value to bound
Returns:
The value bounded between min and max

getPrecisionString

public static java.lang.String getPrecisionString(int leading,
                                                  int precision)
Public function to return a string to use in the DecimalFormat constructor, provided an integer. This function is called as the argument to a DecimalFormat construction and will provide a string with the number of 0's after the decimal point as defined by the supplied precision value

Parameters:
leading - Specifies the number of leading zeros (to the left of the decimal point)
precision - Specifies the number of trailing zeros (to the right of the decimal point)
Returns:
The format string for the DecimalFormat construction

getIntOfDouble

public static int getIntOfDouble(double value)
This function casts the double to an int, effectively returning just the integer portion of the double value. This function gets the integer portion of the double provided. All numbers to the left of the decimal point, including sign.

Parameters:
value - The double value whose integer part is needed
Returns:
The integer part of the double value

getDecimalOfDouble

public static double getDecimalOfDouble(double a)
This function gets all numbers to the right of the decimal of the double provided, including sign.

Parameters:
a - Double value to extract the right side from
Returns:
A double representing that part of the input value to the right of the decimal point

decimalToDMS

public static java.lang.String decimalToDMS(double value,
                                            int precision)
Function to return a string in Degree:Minute:Second format, provided a decimal value. This function converts decimal degrees to DMS format

Parameters:
value - The value to convert to DMS format
precision - The precision of the seconds in the DMS string
Returns:
A string representing the DMS format of value

decimalToDMSDIRV

public static java.lang.String decimalToDMSDIRV(double value,
                                                int precision)
Utility to convert signed latitude degree.decimal values to DMS strings with directions added. If value is positive, the DMS string will have an 'N' appended; if negative, an 'S' will be appended to the DMS string.

Parameters:
value - The signed degree value to convert to a DMS string
precision - The precision of the seconds value in the string
Returns:
The DMS string with the added direction

decimalToDMSDIRH

public static java.lang.String decimalToDMSDIRH(double value,
                                                int precision)
Utility to convert signed longitude degree.decimal values to DMS strings with directions added. If value is positive, the DMS string will have an 'E' appended; if negative, a 'W' will be appended to the DMS string.

Parameters:
value - The signed degree value to convert to a DMS string
precision - The precision of the seconds value in the string
Returns:
The DMS string with the added direction

decimalToTimeHMS

public static java.lang.String decimalToTimeHMS(double value,
                                                int precision)
Public function to return a string to use in the format hh:mm:ss provided a double and an int precision. This function is called to return a specified format string for decimal times. The precision affects how many decimal places the seconds term will have in the result.

Parameters:
value - The value to convert to a time string
precision - The number of decimal places to show in the seconds
Returns:
The format string for the DecimalFormat construction

decimalToRAHMS

public static java.lang.String decimalToRAHMS(double value,
                                              int precision)
Public function to return a string to use in the format hh mm ss.s provided a double and an int precision. This function is called to return a specified format string for decimal times. The precision affects how many decimal places the seconds term will have in the result. This functiuon is primarily for converting Right Ascension values, as the decimal supplied is divided by 15 prior to conversion.

Parameters:
value - The value to convert to a time string
precision - The number of decimal places to show in the seconds
Returns:
The formatted string for Right Ascension