com.oziexplorer
Class SpatialVector
java.lang.Object
com.oziexplorer.SpatialVector
public class SpatialVector
- extends Object
This class represents (distance, bearing) vectors.
Distances are in metres and bearings are in decimal degrees.
Copyright 2011 Alan Burlison, . All rights reserved.
Use is subject to license terms, see
LICENSE.txt.
Field Summary |
protected double |
bearing
The bearing component of the vector, in decimal degrees. |
protected static double |
bearingComparisonAccuracy
The accuracy of bearing comparisons, in decimal degrees. |
protected double |
distance
The distance component of the vector, in metres. |
Constructor Summary |
SpatialVector(double distance,
double bearing)
Create a new spatial vector. |
Method Summary |
boolean |
equals(Object that)
Test if two vectors are equal. |
double |
getBearing()
Return the bearing component of the vector, in decimal degrees. |
static double |
getBearingComparisonAccuracy()
Return the accuracy of bearing comparisons, in decimal degrees. |
double |
getDistance()
Return the distance component of the vector, in metres. |
int |
hashCode()
Return the hash code for this object. |
static void |
setBearingComparisonAccuracy(double bearingComparisonAccuracy)
Set the accuracy of bearing comparisons, in decimal degrees. |
String |
toString()
Return a string representation of the spatial vector,
as "(distance, bearing)" |
distance
protected final double distance
- The distance component of the vector, in metres.
bearing
protected final double bearing
- The bearing component of the vector, in decimal degrees.
bearingComparisonAccuracy
protected static double bearingComparisonAccuracy
- The accuracy of bearing comparisons, in decimal degrees.
SpatialVector
public SpatialVector(double distance,
double bearing)
- Create a new spatial vector.
- Parameters:
distance
- the vector distance, in metres.bearing
- the vector bearing, in decimal degrees.
getDistance
public double getDistance()
- Return the distance component of the vector, in metres.
- Returns:
- the distance, in metres.
getBearing
public double getBearing()
- Return the bearing component of the vector, in decimal degrees.
- Returns:
- the bearing, in decimal degrees.
equals
public boolean equals(Object that)
- Test if two vectors are equal. The vectors will compare as equal if
the distances are within
Position.getComparisonAccuracy()
and the
bearings are within getBearingComparisonAccuracy()
of each other. The default bearing accuracy is 0.5 degrees.
- Overrides:
equals
in class Object
- Parameters:
that
- the object to compare against.
- Returns:
- true if the objects are equal, within the specified bounds..
hashCode
public int hashCode()
- Return the hash code for this object.
- Overrides:
hashCode
in class Object
- Returns:
- the hash code for this object.
toString
public String toString()
- Return a string representation of the spatial vector,
as "(distance, bearing)"
- Overrides:
toString
in class Object
- Returns:
- a string representation of the spatial vector.
getBearingComparisonAccuracy
public static double getBearingComparisonAccuracy()
- Return the accuracy of bearing comparisons, in decimal degrees.
The default value is 0.5 degrees.
- Returns:
- the accuracy of bearing comparisons, in decimal degrees.
setBearingComparisonAccuracy
public static void setBearingComparisonAccuracy(double bearingComparisonAccuracy)
- Set the accuracy of bearing comparisons, in decimal degrees.
The default value is 0.5 degrees.
- Parameters:
bearingComparisonAccuracy
- the accuracy of bearing comparisons,
in decimal degrees.