public class Utilities extends Object
Latest Modification:
Date: April 28, 2005 Time: 1428:57 Author: Terry D. Norbraten Version: 1.12 Comments: Added a debugOut() method that accepts StringBuffers
Modifier and Type | Field and Description |
---|---|
static double |
DEGREESPERRADIAN |
static double |
FEETPERMETER
Conversion for Meters to Feet
|
static DecimalFormat |
fiveDecimalPlaces
fiveDecimalPlaces.format(x) provides output value to 5 decimal places, without trailing zeroes
|
static DecimalFormat |
fiveDecimalPlacesFixed
fiveDecimalPlacesFixed.format(x) provides output value to 5 decimal places, with trailing zeroes
|
static DecimalFormat |
fourDecimalPlaces
fourDecimalPlaces.format(x) provides output value to 4 decimal places, without trailing zeroes
|
static DecimalFormat |
fourDecimalPlacesFixed
fourDecimalPlacesFixed.format(x) provides output value to 4 decimal places, with trailing zeroes
|
static double |
FPS_TO_KNOTS |
static double |
KNOTS_TO_FPS |
static double |
KNOTS_TO_MPS |
static double |
METERSPERFOOT
Conversion for Feet to Meters
|
static double |
MICROSECONDS_PER_SECOND
Conversion factor, microseconds to seconds
|
static double |
MILLISECONDS_PER_SECOND
Conversion factor, milliseconds to seconds
|
static double |
MPS_TO_KNOTS |
static double |
NANOSECONDS_PER_SECOND
Conversion factor, nanoseconds to seconds
|
static DecimalFormat |
oneDecimalPlace
oneDecimalPlace.format(x) provides output value to 1 decimal place, with trailing zero if
|
static double |
RADIANSPERDEGREE |
static DecimalFormat |
sevenDecimalPlaces
sevenDecimalPlaces.format(x) provides output value to 7 decimal places, without trailing zeroes
|
static DecimalFormat |
sevenDecimalPlacesFixed
sevenDecimalPlacesFixed.format(x) provides output value to 7 decimal places, with trailing zeroes
|
static DecimalFormat |
sixDecimalPlaces
sixDecimalPlaces.format(x) provides output value to 6 decimal places, without trailing zeroes
|
static DecimalFormat |
sixDecimalPlacesFixed
sixDecimalPlacesFixed.format(x) provides output value to 6 decimal places, with trailing zeroes
|
static DecimalFormat |
threeDecimalPlaces
threeDecimalPlaces.format(x) provides output value to 3 decimal places, without trailing zeroes
|
static DecimalFormat |
threeDecimalPlacesFixed
threeDecimalPlacesFixed.format(x) provides output value to 3 decimal places, with trailing zeroes
|
static DecimalFormat |
twoDecimalPlaces
twoDecimalPlaces.format(x) provides output value to 2 decimal places, without trailing zeroes
|
static DecimalFormat |
twoDecimalPlacesFixed
twoDecimalPlacesFixed.format(x) provides output value to 2 decimal places, with trailing zeroes
|
static int |
UTILITIES_UDP_MAX_DATA_SIZE |
static int |
UTILITIES_UDP_PORT
A quick bit of hackery to pipe executing mission data through to mission viewers
|
Constructor and Description |
---|
Utilities() |
Modifier and Type | Method and Description |
---|---|
static double |
clamp(double value,
double bound1,
double bound2,
String description)
Restricts an input number to an arbitrary range
|
static double |
clamp(double value,
double bound,
String description)
Restricts an input number to an arbitrary range around zero
|
static void |
debugOut(String msg)
Prints debug messages to the console (if enabled and available)
|
static void |
debugOut(StringBuffer bfr)
Prints debug messages to the console (tdn)
|
static double |
distance(double[] pt1,
double[] pt2)
Returns the Euclidian distance between two points
|
static int |
dsign(double operand)
Determines the sign of the operand (negative, 0, or positive
|
static int |
dsign(int operand)
Determines the sign of the operand (negative, 0, or positive
|
static double |
dtanh(double value)
Returns the signed magnitude of an input value up to a maximum of 1.0
|
static String |
formatHhmmss(double time)
Come back with a hh:mm:ss string based on seconds
|
static String |
formatTimestamp(double time)
Provide time with hh:mm:ss string based on seconds
|
static double |
hTan(double x) |
static double |
normalize180(double angle)
Normalizes an angular measurement (degrees) to the range (-180..180]
|
static double |
normalize2Pi(double angle)
Normalizes an angular measurement (radians) to the range (0..2PI]
|
static double |
normalize360(double angle)
Normalizes an angular measurement (degrees) to the range (0..360]
|
static double |
normalizePi(double angle)
Normalizes an angular measurement (radians) to the range (-PI..PI]
|
static double |
parseDouble(String s)
Parses a double from a string (returns 0.0 if no parsable double present)
|
static int |
parseInt(String s)
Parses an integer from a string (returns 0.0 if no parsable double present)
|
static double |
round(double number,
int places)
Rounds a number off to a specified number of decimal places
|
static void |
traceOut(Point2D p)
Used, probably temporarily, to display realtime point on 2D display
|
static void |
traceOut(String msg)
Prints debug messages to the console (if available)
|
public static final DecimalFormat oneDecimalPlace
public static final DecimalFormat twoDecimalPlaces
public static final DecimalFormat threeDecimalPlaces
public static final DecimalFormat fourDecimalPlaces
public static final DecimalFormat fiveDecimalPlaces
public static final DecimalFormat sixDecimalPlaces
public static final DecimalFormat sevenDecimalPlaces
public static final DecimalFormat twoDecimalPlacesFixed
public static final DecimalFormat threeDecimalPlacesFixed
public static final DecimalFormat fourDecimalPlacesFixed
public static final DecimalFormat fiveDecimalPlacesFixed
public static final DecimalFormat sixDecimalPlacesFixed
public static final DecimalFormat sevenDecimalPlacesFixed
public static final double FEETPERMETER
public static final double METERSPERFOOT
public static final double DEGREESPERRADIAN
public static final double RADIANSPERDEGREE
public static final double FPS_TO_KNOTS
public static final double MPS_TO_KNOTS
public static final double KNOTS_TO_FPS
public static final double KNOTS_TO_MPS
public static final double NANOSECONDS_PER_SECOND
public static final double MICROSECONDS_PER_SECOND
public static final double MILLISECONDS_PER_SECOND
public static final int UTILITIES_UDP_PORT
public static final int UTILITIES_UDP_MAX_DATA_SIZE
public static String formatTimestamp(double time)
time
- secondspublic static String formatHhmmss(double time)
time
- secondspublic static double normalize180(double angle)
angle
- angle to be normalizedpublic static double normalize360(double angle)
angle
- angle to be normalizedpublic static double normalizePi(double angle)
angle
- angle to be normalizedpublic static double normalize2Pi(double angle)
angle
- angle to be normalizedpublic static double clamp(double value, double bound1, double bound2, String description)
value
- value to be clampedbound1
- upper or lower boundary of rangebound2
- upper or lower boundary of rangedescription
- description of the value being clampedpublic static double clamp(double value, double bound, String description)
value
- value to be clampedbound
- upper/lower boundary of allowed range errordescription
- description of the value being clampedpublic static double parseDouble(String s)
s
- string to be parsedpublic static int parseInt(String s)
s
- string to be parsedpublic static double round(double number, int places)
number
- to be roundedplaces
- to round topublic static int dsign(int operand)
operand
- public static int dsign(double operand)
operand
- public static double dtanh(double value)
value
- public static double distance(double[] pt1, double[] pt2)
pt1
- double[2] with the Cartesian coordinates of the first pointpt2
- double[2] with the Cartesian coordinates of the second pointpublic static void debugOut(String msg)
msg
- message to be printedpublic static void debugOut(StringBuffer bfr)
bfr
- message to be printedpublic static void traceOut(String msg)
msg
- message to be printedpublic static void traceOut(Point2D p)
p
- public static double hTan(double x)
x
-