Class LocationElement
java.lang.Object
talonsoalbi_at_gmail_dot_com.ssoxmatch.ephem.LocationElement
- All Implemented Interfaces:
Serializable
This is a convenience class used for passing around spherical coordinates. Units are radians for longitude and latitude, AU for distance.
- Author:
- talonso
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.LocationElement(double[] vector) Vector constructor.LocationElement(double lon, double lat, double rad) Explicit constructor. -
Method Summary
Modifier and TypeMethodDescriptionclone()To clone the object.booleanReturns true if the input object is equals to this instance.double[]get()Get all values in this instance as a vector.static doublegetAngularDistance(LocationElement loc1, LocationElement loc2) Obtain angular distance between two spherical coordinates.static doubleObtain approximate angular distance between two spherical coordinates.static doubleObtain position angle between two spherical coordinates.doubleGets the latitude.static doublegetLinearDistance(LocationElement loc1, LocationElement loc2) Obtain linear distance between two spherical positions.doubleGets the longitude.static LocationElementgetMidPoint(LocationElement loc1, LocationElement loc2) Obtain the direction between two spherical positions.static doublegetPositionAngle(LocationElement loc1, LocationElement loc2) Obtain exact position angle between two spherical coordinates.doubleGets the radius.double[]Transforms a LocationElement into a set of rectangular coordinates x, y, z.inthashCode()voidmove(double dlon, double dlat, double dr) Moves this position a given amount in each axis.static double[]Transforms a LocationElement into a set of rectangular coordinates x, y, z.static double[]Transforms a LocationElement into a set of rectangular coordinates x, y, z, using approximate trigonometric functions.static LocationElementparseRectangularCoordinates(double[] v) Transforms rectangular coordinates x, y, z contained in an array to a LocationElement.static LocationElementparseRectangularCoordinates(double x, double y, double z) Transforms rectangular coordinates x, y, z to a LocationElement.static LocationElementparseRectangularCoordinatesFast(double[] v) Transforms rectangular coordinates x, y, z contained in an array to a LocationElement.static LocationElementparseRectangularCoordinatesFast(double x, double y, double z) Transforms rectangular coordinates x, y, z contained in an array to a LocationElement.voidset(double[] vector) Set all members of this instance from a vector.voidset(double lon, double lat, double rad) Set all members of this instance individually.voidsetRadius(double d) Set the radius.static doublesolveSphericalTriangle(LocationElement locA, LocationElement locP, LocationElement locP1, boolean approx) Solves an spherical triangle return the angle between the positions locP and locP1 as seen from locA.voidtoOffset(double dlon, double dlat) Moves this position a given amount in each axis, setting the location to a given point with some offset.toString()Returns a String representation of this object.
-
Constructor Details
-
LocationElement
public LocationElement()Default constructor. -
LocationElement
public LocationElement(double lon, double lat, double rad) Explicit constructor.- Parameters:
lon- longitude.lat- latitude.rad- radius.
-
LocationElement
public LocationElement(double[] vector) Vector constructor.- Parameters:
vector- { lon, lat, rad }
-
-
Method Details
-
getLatitude
public double getLatitude()Gets the latitude.- Returns:
- The latitude value of this instance.
-
getLongitude
public double getLongitude()Gets the longitude.- Returns:
- The longitude value of this instance.
-
getRadius
public double getRadius()Gets the radius.- Returns:
- The radius value of this instance.
-
get
public double[] get()Get all values in this instance as a vector.The vector is an array of three doubles, longitude, latitude, radius.
- Returns:
- v[0] = longitude, v[1] = latitude, v[2] = radius.
-
setRadius
public void setRadius(double d) Set the radius.- Parameters:
d- The new radius value.
-
set
public void set(double[] vector) Set all members of this instance from a vector.The vector is an array of three doubles, longitude, latitude, radius, in that order.
- Parameters:
vector- v[0] = longitude, v[1] = latitude, v[2] = radius.
-
set
public void set(double lon, double lat, double rad) Set all members of this instance individually.- Parameters:
lon- The new longitude.lat- The new latitude.rad- The new radius.
-
parseRectangularCoordinates
Transforms rectangular coordinates x, y, z contained in an array to a LocationElement. Coordinate system is independent: equatorial, ecliptic, or any other.- Parameters:
v- (x, y, z) vector.- Returns:
- Location object.
-
parseRectangularCoordinatesFast
Transforms rectangular coordinates x, y, z contained in an array to a LocationElement. Coordinate system is independent: equatorial, ecliptic, or any other. This method uses FastMath.atan2(double, double) and FastMath.asin(double) methods.- Parameters:
v- (x, y, z) vector.- Returns:
- Location object.
-
parseRectangularCoordinatesFast
Transforms rectangular coordinates x, y, z contained in an array to a LocationElement. Coordinate system is independent: equatorial, ecliptic, or any other. This method calls parseRectangularCoordinatesFast(double[]).- Parameters:
x- X coordinate.y- Y coordinate.z- Z coordinate.- Returns:
- Location object.
-
parseRectangularCoordinates
Transforms rectangular coordinates x, y, z to a LocationElement. Coordinate system is independent: equatorial, ecliptic, or any other.- Parameters:
x- X coordinate.y- Y coordinate.z- Z coordinate.- Returns:
- Location object.
-
parseLocationElement
Transforms a LocationElement into a set of rectangular coordinates x, y, z.- Parameters:
loc- Location object.- Returns:
- Array with (x, y, z) vector.
-
parseLocationElementFast
Transforms a LocationElement into a set of rectangular coordinates x, y, z, using approximate trigonometric functions.- Parameters:
loc- Location object.- Returns:
- Array with (x, y, z) vector.
-
getRectangularCoordinates
public double[] getRectangularCoordinates()Transforms a LocationElement into a set of rectangular coordinates x, y, z.- Returns:
- Array with (x, y, z) vector.
-
getLinearDistance
Obtain linear distance between two spherical positions.- Parameters:
loc1- Location object.loc2- Location object.- Returns:
- Linear distance.
-
getMidPoint
Obtain the direction between two spherical positions.- Parameters:
loc1- Location object.loc2- Location object.- Returns:
- The midpoint.
-
solveSphericalTriangle
public static double solveSphericalTriangle(LocationElement locA, LocationElement locP, LocationElement locP1, boolean approx) Solves an spherical triangle return the angle between the positions locP and locP1 as seen from locA.- Parameters:
locA- A position.locP- P position.locP1- P1 position.approx- True for an approximate and faster computation.- Returns:
- The spherical angle.
-
getAngularDistance
Obtain angular distance between two spherical coordinates.- Parameters:
loc1- Location object.loc2- Location object.- Returns:
- The distance in radians, from 0 to PI.
-
getApproximateAngularDistance
Obtain approximate angular distance between two spherical coordinates. Almost exact result- Parameters:
loc1- Location object.loc2- Location object.- Returns:
- The distance in radians, from 0 to PI.
-
getApproximatePositionAngle
Obtain position angle between two spherical coordinates. Good performance.- Parameters:
loc1- Location object.loc2- Location object.- Returns:
- The position angle in radians.
-
getPositionAngle
Obtain exact position angle between two spherical coordinates. Performance will be poor.- Parameters:
loc1- Location object.loc2- Location object.- Returns:
- The position angle in radians.
-
clone
To clone the object. -
equals
Returns true if the input object is equals to this instance. -
hashCode
public int hashCode() -
toString
Returns a String representation of this object. -
move
public void move(double dlon, double dlat, double dr) Moves this position a given amount in each axis.- Parameters:
dlon- Displacement in longitude, radians. It is a pure incremental modification.dlat- Displacement in latitude, radians.dr- Displacemente in distance, in units of the distance.
-
toOffset
public void toOffset(double dlon, double dlat) Moves this position a given amount in each axis, setting the location to a given point with some offset.- Parameters:
dlon- Displacement in longitude, radians. This increment is respect the sky plain, not a coordinate incremental offset.dlat- Displacement in latitude, radians.
-