|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.mars_sim.msp.simulation.Coordinates
public class Coordinates
Spherical Coordinates. Represents a location on virtual Mars in spherical coordinates. It provides some useful methods involving those coordinates, as well as some static methods for general coordinate calculations.
Constructor Summary | |
---|---|
Coordinates(Coordinates originalCoordinates)
Clone constructor |
|
Coordinates(double phi,
double theta)
Constructs a Coordinates object |
|
Coordinates(java.lang.String latitude,
java.lang.String longitude)
Constructor with a latitude and longitude string. |
Method Summary | |
---|---|
Coordinates |
convertRectToSpherical(double x,
double y)
Converts linear rectangular XY position change to spherical coordinates |
Coordinates |
convertRectToSpherical(double x,
double y,
double rho)
Converts linear rectangular XY position change to spherical coordinates with rho value for map. |
void |
convertRectToSpherical(double x,
double y,
double rho,
Coordinates newCoordinates)
Converts linear rectangular XY position change to spherical coordinates with rho value for map. |
boolean |
equals(java.lang.Object otherCoords)
Returns true if coordinates have equal phi and theta values |
static IntPoint |
findRectPosition(Coordinates newCoords,
Coordinates centerCoords,
double rho,
int half_map,
int low_edge)
Converts spherical coordinates to rectangular coordinates. |
IntPoint |
findRectPosition(double newPhi,
double newTheta,
double rho,
int half_map,
int low_edge)
Converts spherical coordinates to rectangular coordinates. |
double |
getAngle(Coordinates otherCoords)
Returns the arc angle in radians between this location and the given coordinates |
double |
getCosPhi()
cosine of phi |
double |
getCosTheta()
cosine of theta |
Direction |
getDirectionToPoint(Coordinates otherCoords)
Returns angle direction to another location on surface of sphere 0 degrees is north (clockwise) |
double |
getDistance(Coordinates otherCoords)
Returns the distance in kilometers between this location and the given coordinates |
java.lang.String |
getFormattedLatitudeString()
Gets a common formatted string to represent latitude for this location. |
java.lang.String |
getFormattedLongitudeString()
Gets a common formatted string to represent longitude for this location. |
java.lang.String |
getFormattedString()
Gets a common formatted string to represent this location. |
Coordinates |
getNewLocation(Direction direction,
double distance)
Gets a new location with a given direction and distance from the current location. |
double |
getPhi()
phi accessor |
static double |
getRandomLatitude()
Gets a random latitude. |
static double |
getRandomLongitude()
Gets a random longitude. |
double |
getSinPhi()
sine of phi. |
double |
getSinTheta()
sine of theta |
double |
getTheta()
theta accessor |
int |
hashCode()
Gets the hash code for this object. |
static double |
parseLatitude(java.lang.String latitude)
Parse a latitude string into a phi value. |
static double |
parseLongitude(java.lang.String longitude)
Parse a longitude string into a theta value. |
void |
setCoords(Coordinates newCoordinates)
Set coordinates |
void |
setPhi(double newPhi)
phi mutator |
void |
setTheta(double newTheta)
theta mutator |
java.lang.String |
toString()
Generate a string representation of this object. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Coordinates(double phi, double theta)
phi
- the phi angle of the spherical coordinatetheta
- the theta angle of the spherical coordinatepublic Coordinates(Coordinates originalCoordinates)
originalCoordinates
- the Coordinates object to be clonedpublic Coordinates(java.lang.String latitude, java.lang.String longitude) throws java.lang.Exception
latitude
- String representing latitude value. ex. "25.344 N" or "25.344? N"longitude
- String representing longitude value. ex. "63.5532 W" or "63.5532? W"
java.lang.Exception
- if latitude or longitude strings are invalid.Method Detail |
---|
public java.lang.String toString()
toString
in class java.lang.Object
getFormattedString()
public double getPhi()
public void setPhi(double newPhi)
newPhi
- the new phi angle value for the coordinatepublic double getTheta()
public void setTheta(double newTheta)
newTheta
- the new theta angle value for the coordinatepublic double getSinPhi()
public double getSinTheta()
public double getCosPhi()
public double getCosTheta()
public void setCoords(Coordinates newCoordinates)
newCoordinates
- Coordinates object who's location should be matched by
this Coordinates objectpublic boolean equals(java.lang.Object otherCoords)
equals
in class java.lang.Object
otherCoords
- Coordinates object to be matched against
public int hashCode()
hashCode
in class java.lang.Object
public double getAngle(Coordinates otherCoords)
otherCoords
- remote Coordinates object
public double getDistance(Coordinates otherCoords)
otherCoords
- remote Coordinates object
public java.lang.String getFormattedString()
getFormattedLongitudeString()
,
getFormattedLatitudeString()
public java.lang.String getFormattedLongitudeString()
public java.lang.String getFormattedLatitudeString()
public static IntPoint findRectPosition(Coordinates newCoords, Coordinates centerCoords, double rho, int half_map, int low_edge)
newCoords
- offsetted locationcenterCoords
- location of the center of the maprho
- diameter of planet (in km)half_map
- half the map's width (in pixels)low_edge
- lower edge of map (in pixels)
public IntPoint findRectPosition(double newPhi, double newTheta, double rho, int half_map, int low_edge)
newPhi
- the new phi coordinatenewTheta
- the new theta coordinaterho
- diameter of planet (in km)half_map
- half the map's width (in pixels)low_edge
- lower edge of map (in pixels)
public Coordinates convertRectToSpherical(double x, double y)
x
- change in x value (in km)y
- change in y value (in km)
public Coordinates convertRectToSpherical(double x, double y, double rho)
x
- change in x value (in km)y
- change in y value (in km)rho
- rho value of map used
public void convertRectToSpherical(double x, double y, double rho, Coordinates newCoordinates)
x
- change in x value (in km)y
- change in y value (in km)rho
- rho value of map usednewCoordinates
- Coordinates object to put the result inpublic Direction getDirectionToPoint(Coordinates otherCoords)
otherCoords
- target location
public Coordinates getNewLocation(Direction direction, double distance)
direction
- direction to new locationdistance
- distance to new location (in km)
public static double parseLatitude(java.lang.String latitude) throws java.text.ParseException
latitude
- as string
java.text.ParseException
- if latitude string could not be parsed.public static double parseLongitude(java.lang.String longitude) throws java.text.ParseException
longitude
- as string
java.text.ParseException
- if longitude string could not be parsed.public static double getRandomLatitude()
public static double getRandomLongitude()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |