Package com.anylogic.engine
- java.lang.Object
- com.anylogic.engine.Point
- All Implemented Interfaces:
Locatable2D
,Serializable
,Cloneable
- Direct Known Subclasses:
Position
public class Point extends Object implements Serializable, Cloneable, Locatable2D
Class representing Point structure: three coordinates (x, y, z).
Used in various utility methods in the AnyLogic Engine and in some AnyLogic libraries.
For those utilities which operate in 2D space (x, y), the third (z) coordinate is simply ignored
For those utilities which operate in 2D space (x, y), the third (z) coordinate is simply ignored
- Author:
- AnyLogic North America, LLC https://anylogic.com
- See Also:
- Serialized Form
Modifier and Type | Field | Description |
---|---|---|
double | x |
The x coordinate of this Point.
|
double | y |
The y coordinate of this Point.
|
double | z |
The z coordinate of this Point.
|
Constructor | Description |
---|---|
Point() |
Creates new point with zero (0, 0, 0) coordinates
|
Point |
Creates new point with the given (x, y) coordinates.
|
Point |
Creates new point with the given coordinates.
|
Point |
Creates a copy of the given point
|
Modifier and Type | Method | Description |
---|---|---|
Point | add |
Adds
p to this point: moves this point by the offset specified by the given point p . |
Point | clone() | |
Point | clone |
Fills the given
output instance (if it is not null ) or
otherwise creates a copy of this object and returns it |
double | distance |
Returns the distance from this Point to the specified point.
|
double | distance |
Returns the distance from this Point to the specified point.
|
double | distance |
Returns the distance from this Point to the specified Point.
|
double | distance2D |
Returns the distance from this Point to the specified Point.
|
double | distanceGIS |
Returns the distance from this Point to the specified (lat, lon) on GIS surface.
|
double | distanceGIS |
Returns the distance from this Point to the specified (lat, lon) on GIS surface.
|
double | distanceGIS |
Returns the distance from this Point to the specified Point on GIS surface.
|
double | distanceGIS |
Returns the distance from this Point to the specified Point on GIS surface.
|
double | distanceSq |
Returns the square of the distance from this Point to the specified
point.
|
double | distanceSq |
Returns the square of the distance from this Point to the specified
point.
This method is useful for comparing different distances, finding nearest point etc. |
double | distanceSq |
Returns the square of the distance from this Point to the specified
Point.
This method is useful for comparing different distances, finding nearest point etc. |
double | distanceSq2D |
Returns the square of the distance from this Point to the specified
Point.
|
boolean | equals |
Returns
true if this point has the same
coordinates as in the given point, within the given relative
error. |
boolean | equals |
Returns
true if the given object is Point and it has
exactly the same coordinates as in this Point. |
boolean | equals2D |
Returns
true if this point has the same (x, y)
coordinates (z is ignored) as in the given point, within the given relative
error. |
double | getLatitude() |
Returns the latitude of this Point
|
double | getLongitude() |
Returns the longitude if this Point
|
double | getX() |
Returns the x coordinate of this Point
|
double | getY() |
Returns the y coordinate of this Point
|
double | getZ() |
Returns the z coordinate of this Point
|
int | hashCode() | |
Point | setLatLon |
Set latitude and longitude of this Point
|
Point | setLocation |
Sets the location of this Point to the given coordinates.
|
Point | setLocation |
Sets the location of this Point to the given coordinates.
|
Point | setLocation |
Sets the location of this Point to the same coordinates as in the given
Point object.
|
Point | sub |
Subtracts
p from this point: moves this point by the negative offset specified by the given point p . |
String | toString() |
public double x
The x coordinate of this Point.
In case of GIS space this is the latitude of this Point,
measured in degrees (-90 ... (South) ... 0 ... (North) ... +90)
public double y
The y coordinate of this Point.
In case of GIS space this is the longitude of the Point,
measured in degrees (-180 ... (West) ... 0 ... (East) ... +180)
public double z
The z coordinate of this Point.
public Point()
Creates new point with zero (0, 0, 0) coordinates
public Point(Point p)
Creates a copy of the given point
- Parameters:
p
- the original point
public Point(double x, double y, double z)
Creates new point with the given coordinates.
- Parameters:
x
- the x coordinate of the Pointy
- the y coordinate of the Pointz
- the z coordinate of the Point
public Point(double x, double y)
Creates new point with the given (x, y) coordinates. (z coordinate is set
to zero)
- Parameters:
x
- the x coordinate of the Point In case of GIS space this is the latitude of the Point, measured in degrees (-90 ... (South) ... 0 ... (North) ... +90)y
- the y coordinate of the Point In case of GIS space this is the longitude of the Point, measured in degrees (-180 ... (West) ... 0 ... (East) ... +180)
public double getX()
Returns the x coordinate of this Point
- Specified by:
getX
in interfaceLocatable2D
- Returns:
- the x coordinate of this Point
public double getY()
Returns the y coordinate of this Point
- Specified by:
getY
in interfaceLocatable2D
- Returns:
- the y coordinate of this Point
public double getZ()
Returns the z coordinate of this Point
- Returns:
- the z coordinate of this Point
public Point setLocation(double x, double y, double z)
Sets the location of this Point to the given coordinates.
- Parameters:
x
- the new x coordinate of this Pointy
- the new y coordinate of this Pointz
- the new z coordinate of this Point- Returns:
- this Point object
public Point setLocation(double x, double y)
Sets the location of this Point to the given coordinates. (z coordinate
is not changed)
- Parameters:
x
- the new x coordinate of this Point In case of GIS space this is the latitude of this Point, measured in degrees (-90 ... (South) ... 0 ... (North) ... +90)y
- the y coordinate of the Point In case of GIS space this is the longitude of this Point, measured in degrees (-180 ... (West) ... 0 ... (East) ... +180)- Returns:
- this Point object
public Point setLatLon(double lat, double lon)
Set latitude and longitude of this Point
- Parameters:
lat
- the latitude coordinate of the Point measured in degrees (-90 ... (South) ... 0 ... (North) ... +90)lon
- the longitude coordinate of the Point measured in degrees (-180 ... (West) ... 0 ... (East) ... +180)- Returns:
- this Point object
public Point setLocation(Point p)
Sets the location of this Point to the same coordinates as in the given
Point object.
- Parameters:
p
- the specified Point to which to set this Point- Returns:
- this Point object
public Point add(Point p)
Adds
Returns
p
to this point: moves this point by the offset specified by the given point p
.
In other words, increments coordinates of this point by the values of p
's coordinates.Returns
this
point for convenience.- Parameters:
p
- the point which will be added to this point- Returns:
- this point
public Point sub(Point p)
Subtracts
Returns
p
from this point: moves this point by the negative offset specified by the given point p
.
In other words, decrements coordinates of this point by the values of p
's coordinates.Returns
this
point for convenience.- Parameters:
p
- the point which will be subtracted from this point- Returns:
- this point
public double distanceSq(Point p)
Returns the square of the distance from this Point to the specified
Point.
This method is useful for comparing different distances, finding nearest point etc. because of better performance compared with
This method is useful for comparing different distances, finding nearest point etc. because of better performance compared with
distance()
- Parameters:
p
- the specified point to be measured against this Point- Returns:
- the square of the distance between this Point and the specified Point.
public double distanceSq2D(Point p)
Returns the square of the distance from this Point to the specified
Point. Z coordinate isn't used in calculation.
This method is useful for comparing different distances, finding nearest point etc. because of better performance compared with
This method is useful for comparing different distances, finding nearest point etc. because of better performance compared with
distance()
- Parameters:
p
- the specified point to be measured against this Point- Returns:
- the square of the distance between this Point and the specified Point in the XY-plane (2D).
public double distanceSq(double px, double py)
Returns the square of the distance from this Point to the specified
point. Z coordinate isn't used in calculation.
This method is useful for comparing different distances, finding nearest point etc. because of better performance compared with
This method is useful for comparing different distances, finding nearest point etc. because of better performance compared with
distance()
- Parameters:
px
- the x coordinate of the specified point to be measured against this Pointpy
- the y coordinate of the specified point to be measured against this Point- Returns:
- the square of the distance between this Point and the specified point in the XY-plane (2D).
public double distance(double px, double py)
Returns the distance from this Point to the specified point. Z coordinate
isn't used in calculation.
- Parameters:
px
- the x coordinate of the specified point to be measured against this Pointpy
- the y coordinate of the specified point to be measured against this Point- Returns:
- the distance between this Point and the specified point.
public double distanceSq(double px, double py, double pz)
Returns the square of the distance from this Point to the specified
point.
This method is useful for comparing different distances, finding nearest point etc. because of better performance compared with
This method is useful for comparing different distances, finding nearest point etc. because of better performance compared with
distance()
- Parameters:
px
- the x coordinate of the specified point to be measured against this Pointpy
- the y coordinate of the specified point to be measured against this Pointpz
- the z coordinate of the specified point to be measured against this Point- Returns:
- the square of the distance between this Point and the specified point.
public double distance(double px, double py, double pz)
Returns the distance from this Point to the specified point. Z coordinate
isn't used in calculation.
- Parameters:
px
- the x coordinate of the specified point to be measured against this Pointpy
- the y coordinate of the specified point to be measured against this Pointpz
- the z coordinate of the specified point to be measured against this Point- Returns:
- the distance between this Point and the specified point.
public double distance(Point p)
Returns the distance from this Point to the specified Point.
- Parameters:
p
- the specified point to be measured against this Point- Returns:
- the distance between this Point and the specified Point.
public double distanceGIS(Point p)
Returns the distance from this Point to the specified Point on GIS surface.
Latitude and Longitude used.
- Parameters:
p
- the specified point to be measured against this Point- Returns:
- the distance between this Point and the specified Point in meters.
public double distanceGIS(Point p, LengthUnits units)
Returns the distance from this Point to the specified Point on GIS surface.
Latitude and Longitude used.
- Parameters:
p
- the specified point to be measured against this Pointunits
- the units of length- Returns:
- the distance between this Point and the specified Point in given length units.
public double distanceGIS(double lat, double lon)
Returns the distance from this Point to the specified (lat, lon) on GIS surface.
- Parameters:
lat
- the latitude coordinate of the Point measured in degrees (-90 ... (South) ... 0 ... (North) ... +90)lon
- the longitude coordinate of the Point measured in degrees (-180 ... (West) ... 0 ... (East) ... +180)- Returns:
- the distance in meters between this Point and the specified (lat, lon).
public double distanceGIS(double lat, double lon, LengthUnits units)
Returns the distance from this Point to the specified (lat, lon) on GIS surface.
- Parameters:
lat
- the latitude coordinate of the Point measured in degrees (-90 ... (South) ... 0 ... (North) ... +90)lon
- the longitude coordinate of the Point measured in degrees (-180 ... (West) ... 0 ... (East) ... +180)units
- the units of length- Returns:
- the distance in given length units between this Point and the specified (lat, lon).
public double distance2D(Point p)
Returns the distance from this Point to the specified Point. Z coordinate
isn't used in calculation.
- Parameters:
p
- the specified point to be measured against this Point- Returns:
- the distance between this Point and the specified Point in the XY-plane (2D).
public String toString()
public Point clone()
public int hashCode()
public boolean equals(Object obj)
Returns
true
if the given object is Point
and it has
exactly the same coordinates as in this Point. Note that due to numeric
errors there may cases when some calculated point has slightly different
coordinates and hence doesn't match with expected value.public boolean equals(Point p, double relativeError)
Returns
true
if this point has the same
coordinates as in the given point, within the given relative
error. Each pair of coordinates is compared separately using
this formula:|x1 - x2| <= relativeError * max( |x1|, |x2| )
- Parameters:
p
- the point to compare torelativeError
- relative error, applied to each coordinate separately
public boolean equals2D(Point p, double relativeError)
Returns
true
if this point has the same (x, y)
coordinates (z is ignored) as in the given point, within the given relative
error. Each pair of coordinates is compared separately using
this formula:|x1 - x2| <= relativeError * max( |x1|, |x2| )
- Parameters:
p
- the point to compare torelativeError
- relative error, applied to each coordinate separately
public Point clone(Point out)
Fills the given
output
instance (if it is not null
) or
otherwise creates a copy of this object and returns it- Parameters:
out
- the Point object to write to (may benull
)- Returns:
- the given
output
object (if was notnull
) or new Point with coordinates set equal to this object.
public double getLatitude()
Returns the latitude of this Point
- Returns:
- latitude
public double getLongitude()
Returns the longitude if this Point
- Returns:
- longitude