Package org.openstreetmap.josm.data.coor
Class EastNorth
- java.lang.Object
-
- org.openstreetmap.josm.data.coor.Coordinate
-
- org.openstreetmap.josm.data.coor.EastNorth
-
- All Implemented Interfaces:
java.io.Serializable
public class EastNorth extends Coordinate
Northing, Easting of the projected coordinates. This class is immutable.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private static long
serialVersionUID
static EastNorth
ZERO
A zero constant-
Fields inherited from class org.openstreetmap.josm.data.coor.Coordinate
x, y
-
-
Constructor Summary
Constructors Constructor Description EastNorth(double east, double north)
Constructs a newEastNorth
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description EastNorth
add(double dEast, double dNorth)
Adds an offset to thisEastNorth
instance and returns the result.EastNorth
add(EastNorth other)
Adds the coordinates of another EastNorth instance to this one.double
distance(EastNorth en)
Returns the euclidean distance from thisEastNorth
to a specifiedEastNorth
.double
distanceSq(EastNorth en)
Returns the square of the euclidean distance from thisEastNorth
to a specifiedEastNorth
.double
east()
Returns easting.boolean
equalsEpsilon(EastNorth other, double e)
Compares two EastNorth valuesEastNorth
getCenter(EastNorth en2)
Gets the center between twoEastNorth
instances.double
heading(EastNorth other)
Returns the heading, in radians, that you have to use to get from this EastNorth to another.double
heading(EastNorth other, double refHeading)
Behaves exactly likeheading(EastNorth)
ifrefHeading
is0.0
, otherwise gives a heading not relative to north (0.0).EastNorth
interpolate(EastNorth en2, double proportion)
Does a linear interpolation between two EastNorth instances.boolean
isValid()
Replies true if east and north are different from Double.NaN and not infinitedouble
length()
Counts length (distance from [0,0]) of this.double
north()
Returns northing.EastNorth
rotate(EastNorth pivot, double angle)
Returns an EastNorth representing this EastNorth rotated around a given EastNorth by a given angleEastNorth
scale(double s)
Scales thisEastNorth
instance to a given factor and returns the result.EastNorth
subtract(EastNorth other)
Subtracts an east/north value from this point.java.lang.String
toString()
-
Methods inherited from class org.openstreetmap.josm.data.coor.Coordinate
distance, distance, distanceSq, distanceSq, equals, getX, getY, hashCode
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
EastNorth
public EastNorth(double east, double north)
Constructs a newEastNorth
.- Parameters:
east
- eastingnorth
- northing
-
-
Method Detail
-
east
public double east()
Returns easting.- Returns:
- easting
-
north
public double north()
Returns northing.- Returns:
- northing
-
add
public EastNorth add(double dEast, double dNorth)
Adds an offset to thisEastNorth
instance and returns the result.- Parameters:
dEast
- The offset to add in east direction.dNorth
- The offset to add in north direction.- Returns:
- The result.
-
add
public EastNorth add(EastNorth other)
Adds the coordinates of another EastNorth instance to this one.- Parameters:
other
- The other instance.- Returns:
- The new EastNorth position.
-
subtract
public EastNorth subtract(EastNorth other)
Subtracts an east/north value from this point.- Parameters:
other
- The other value to subtract from this.- Returns:
- A point with the new coordinates.
-
scale
public EastNorth scale(double s)
Scales thisEastNorth
instance to a given factor and returns the result.- Parameters:
s
- factor- Returns:
- The result.
-
interpolate
public EastNorth interpolate(EastNorth en2, double proportion)
Does a linear interpolation between two EastNorth instances.- Parameters:
en2
- The other EstNort instance.proportion
- The proportion the other instance influences the result.- Returns:
- The new
EastNorth
position.
-
getCenter
public EastNorth getCenter(EastNorth en2)
Gets the center between twoEastNorth
instances.- Parameters:
en2
- The other instance.- Returns:
- The center between this and the other instance.
-
distance
public double distance(EastNorth en)
Returns the euclidean distance from thisEastNorth
to a specifiedEastNorth
.- Parameters:
en
- the specified coordinate to be measured against thisEastNorth
- Returns:
- the euclidean distance from this
EastNorth
to a specifiedEastNorth
- Since:
- 6166
-
distanceSq
public double distanceSq(EastNorth en)
Returns the square of the euclidean distance from thisEastNorth
to a specifiedEastNorth
.- Parameters:
en
- the specified coordinate to be measured against thisEastNorth
- Returns:
- the square of the euclidean distance from this
EastNorth
to a specifiedEastNorth
- Since:
- 6166
-
length
public double length()
Counts length (distance from [0,0]) of this.- Returns:
- length of this
-
heading
public double heading(EastNorth other)
Returns the heading, in radians, that you have to use to get from this EastNorth to another. Heading is mapped into [0, 2pi)- Parameters:
other
- the "destination" position- Returns:
- heading
-
heading
public double heading(EastNorth other, double refHeading)
Behaves exactly likeheading(EastNorth)
ifrefHeading
is0.0
, otherwise gives a heading not relative to north (0.0). It replies the radians needed to add torefHeading
to get from this EastNorth to another.- Parameters:
other
- the "destination" positionrefHeading
- origin ("false" north if different from0.0
)- Returns:
- heading with respect to
refHeading
as origin - Since:
- 18468
-
isValid
public boolean isValid()
Replies true if east and north are different from Double.NaN and not infinite- Returns:
- true if east and north are different from Double.NaN and not infinite
-
rotate
public EastNorth rotate(EastNorth pivot, double angle)
Returns an EastNorth representing this EastNorth rotated around a given EastNorth by a given angle- Parameters:
pivot
- the center of the rotationangle
- the angle of the rotation- Returns:
- EastNorth rotated object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
equalsEpsilon
public boolean equalsEpsilon(EastNorth other, double e)
Compares two EastNorth values- Parameters:
other
- other east.northe
- epsilon- Returns:
- true if "x" and "y" values are within epsilon
e
of each other
-
-