|
NASA World Wind | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectgov.nasa.worldwind.util.WWMath
public class WWMath
A collection of useful math methods, all static.
| Field Summary | |
|---|---|
static double |
HOUR_TO_MILLIS
|
static double |
METERS_TO_FEET
|
static double |
METERS_TO_KILOMETERS
|
static double |
METERS_TO_MILES
|
static double |
METERS_TO_NAUTICAL_MILES
|
static double |
METERS_TO_YARDS
|
static double |
MINUTE_TO_MILLIS
|
static double |
SECOND_TO_MILLIS
|
static double |
SQUARE_METERS_TO_ACRES
|
static double |
SQUARE_METERS_TO_HECTARES
|
static double |
SQUARE_METERS_TO_SQUARE_FEET
|
static double |
SQUARE_METERS_TO_SQUARE_KILOMETERS
|
static double |
SQUARE_METERS_TO_SQUARE_MILES
|
static double |
SQUARE_METERS_TO_SQUARE_YARDS
|
| Constructor Summary | |
|---|---|
WWMath()
|
|
| Method Summary | |
|---|---|
static double |
clamp(double v,
double min,
double max)
Clamps a value to a given range. |
static double |
computeDistanceFromEye(DrawContext dc,
Extent extent)
Returns the distance in model coordinates from the View eye point to the specified
Extent. |
static double |
computeInterpolationFactor(double v,
double x,
double y)
Returns the interpolation factor for v given the specified range [x, y]. |
static double |
computePolygonArea(java.lang.Iterable<? extends LatLon> locations)
Returns the area enclosed by the specified locations, in angular degrees. |
static double |
computePolygonArea2(java.lang.Iterable<? extends Vec4> points)
Returns the area enclosed by the specified (x, y) points (the z and w coordinates are ignored). |
static java.lang.String |
computePolygonWindingOrder(java.lang.Iterable<? extends LatLon> locations)
Returns the winding order of the polygon described by the specified locations, with respect an axis perpendicular to the (lat, lon) coordinates, and pointing in the direction of "positive elevation". |
static java.lang.String |
computePolygonWindingOrder2(java.lang.Iterable<? extends Vec4> points)
Returns the winding order of the 2D polygon described by the specified (x, y) points (z and w coordinates are ignored), with respect to the positive z axis. |
static double |
computeSizeInWindowCoordinates(DrawContext dc,
Extent extent)
Returns the size in window coordinates of the specified Extent from the current
View. |
static Vec4 |
computeTriangleNormal(Vec4 a,
Vec4 b,
Vec4 c)
Returns the normal vector corresponding to the triangle defined by three vertices (a, b, c). |
static double |
convertHoursToMillis(double hours)
Converts time in hours to time in milliseconds. |
static double |
convertMetersToFeet(double meters)
converts meters to feet. |
static double |
convertMetersToMiles(double meters)
converts meters to miles. |
static double |
convertMillisToHours(double mills)
Converts time in milliseconds to time in hours. |
static double |
convertMillisToMinutes(double millis)
Converts time in milliseconds to time in minutes. |
static double |
convertMillisToSeconds(double millis)
Converts time in milliseconds to time in seconds. |
static double |
convertMinutesToMillis(double minutes)
Converts time in minutes to time in milliseconds. |
static double |
convertSecondsToMillis(double seconds)
Converts time in seconds to time in milliseconds. |
static boolean |
isLocationInside(LatLon location,
java.lang.Iterable<? extends LatLon> locations)
Determines whether a LatLon location is located inside a given polygon. |
static boolean |
isPolygonClosed(java.lang.Iterable<? extends LatLon> locations)
Returns whether the geographic polygon described by the specified locations defines a closed loop. |
static boolean |
isPolygonClosed2(java.lang.Iterable<? extends Vec4> points)
Returns whether the 2D polygon described by the specified (x, y) points defines a closed loop (z and w coordinates are ignored). |
static boolean |
isPowerOfTwo(int value)
Convenience method for testing whether a value is a power of two. |
static double |
logBase2(double value)
Convenience method to compute the log base 2 of a value. |
static double |
mix(double a,
double x,
double y)
Returns the linear interpolation of x and y according to the function: (1 - a) *
x + a * y. |
static double |
mixSmooth(double a,
double x,
double y)
Returns the smooth hermite interpolation of x and y according to the function: (1
- t) * x + t * y, where t = a * a * (3 - 2 * a). |
static int |
powerOfTwoCeiling(int reference)
Returns the value that is the nearest power of 2 greater than or equal to the given value. |
static int |
powerOfTwoFloor(int reference)
Returns the value that is the nearest power of 2 less than or equal to the given value. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final double HOUR_TO_MILLIS
public static final double METERS_TO_FEET
public static final double METERS_TO_KILOMETERS
public static final double METERS_TO_MILES
public static final double METERS_TO_NAUTICAL_MILES
public static final double METERS_TO_YARDS
public static final double MINUTE_TO_MILLIS
public static final double SECOND_TO_MILLIS
public static final double SQUARE_METERS_TO_ACRES
public static final double SQUARE_METERS_TO_HECTARES
public static final double SQUARE_METERS_TO_SQUARE_FEET
public static final double SQUARE_METERS_TO_SQUARE_KILOMETERS
public static final double SQUARE_METERS_TO_SQUARE_MILES
public static final double SQUARE_METERS_TO_SQUARE_YARDS
| Constructor Detail |
|---|
public WWMath()
| Method Detail |
|---|
public static double clamp(double v,
double min,
double max)
v - the value to clamp.min - the floor.max - the ceiling
public static double computeDistanceFromEye(DrawContext dc,
Extent extent)
View eye point to the specified
Extent. If the View eye point is inside the extent, this returns 0.
dc - the DrawContext which the View eye point is obtained from.extent - the extent to compute the distance from.
java.lang.IllegalArgumentException - if either the DrawContext or the extent is null.
public static double computeInterpolationFactor(double v,
double x,
double y)
v given the specified range [x, y]. The
interpolation factor is a number between 0 and 1 (inclusive), representing the value's relative position between
x and y. For example, 0 corresponds to x, 1 corresponds to y,
and anything in between corresponds to a linear combination of x and y.
v - the value to compute the interpolation factor for.x - the first value.y - the second value.
v given the specified range [x, y]public static double computePolygonArea(java.lang.Iterable<? extends LatLon> locations)
locations - the locations which define the geographic polygon.
java.lang.IllegalArgumentException - if locations is null.public static double computePolygonArea2(java.lang.Iterable<? extends Vec4> points)
points - the (x, y) points which define the 2D polygon.
java.lang.IllegalArgumentException - if points is null.public static java.lang.String computePolygonWindingOrder(java.lang.Iterable<? extends LatLon> locations)
locations - the locations which define the geographic polygon.
AVKey.CLOCKWISE if the polygon has clockwise winding order about the positive z axis, and AVKey.COUNTER_CLOCKWISE otherwise.public static java.lang.String computePolygonWindingOrder2(java.lang.Iterable<? extends Vec4> points)
points - the (x, y) points which define the 2D polygon.
public static double computeSizeInWindowCoordinates(DrawContext dc,
Extent extent)
Extent from the current
View. The returned size is an estimate of the Extent's diameter in window
coordinates.
dc - the current draw context, from which the View is obtained from.extent - the extent to compute the window size for.
java.lang.IllegalArgumentException - if either the DrawContext or the extent is null.
public static Vec4 computeTriangleNormal(Vec4 a,
Vec4 b,
Vec4 c)
a - the triangle's first vertex.b - the triangle's second vertex.c - the triangle's third vertex.
java.lang.IllegalArgumentException - if any of the specified vertices are null.public static double convertHoursToMillis(double hours)
hours - time in hours.
public static double convertMetersToFeet(double meters)
meters - the value in meters.
public static double convertMetersToMiles(double meters)
meters - the value in meters.
public static double convertMillisToHours(double mills)
mills - time in milliseconds.
public static double convertMillisToMinutes(double millis)
millis - time in milliseconds.
public static double convertMillisToSeconds(double millis)
millis - time in milliseconds.
public static double convertMinutesToMillis(double minutes)
minutes - time in minutes.
public static double convertSecondsToMillis(double seconds)
seconds - time in seconds.
public static boolean isLocationInside(LatLon location,
java.lang.Iterable<? extends LatLon> locations)
LatLon location is located inside a given polygon.
location - the locationlocations - the list of positions describing the polygon. Last one should be the same as the first one.
public static boolean isPolygonClosed(java.lang.Iterable<? extends LatLon> locations)
locations - the locations which define the geographic polygon.
java.lang.IllegalArgumentException - if the locations are null.public static boolean isPolygonClosed2(java.lang.Iterable<? extends Vec4> points)
points - the (x, y) points which define the 2D polygon.
java.lang.IllegalArgumentException - if the points are null.public static boolean isPowerOfTwo(int value)
value - the value to test for power of 2
public static double logBase2(double value)
value - the value to take the log of.
public static double mix(double a,
double x,
double y)
x and y according to the function: (1 - a) *
x + a * y. The interpolation factor a defines the weight given to each value, and is clamped
to the range [0, 1]. If a is 0 or less, this returns x. If a is 1 or more, this returns
y. Otherwise, this returns the linear interpolation of x and y. For
example, when a is 0.5 this returns (x + y)/2.
a - the interpolation factor.x - the first value.y - the second value.
x and y.
public static double mixSmooth(double a,
double x,
double y)
x and y according to the function: (1
- t) * x + t * y, where t = a * a * (3 - 2 * a). The interpolation factor a
defines the weight given to each value, and is clamped to the range [0, 1]. If a is 0 or less, this
returns x. If a is 1 or more, this returns y. Otherwise, this returns the
smooth hermite interpolation of x and y. Like the linear function mix(double,
double, double), when a is 0.5 this returns (x + y)/2. But unlike the
linear function, the hermite function's slope gradually increases when a is near 0, then gradually
decreases when a is near 1. This is a useful property where a more gradual transition from
x to y is desired.
a - the interpolation factor.x - the first value.y - the second value.
x and y.public static int powerOfTwoCeiling(int reference)
reference - the reference value. The power of 2 returned is greater than or equal to this value.
public static int powerOfTwoFloor(int reference)
reference - the reference value. The power of 2 returned is less than or equal to this value.
|
NASA World Wind | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||