public class Point2D extends Object implements Serializable, Comparable<Point2D>
java.awt.Point
and java.awt.geom.Point2D.Double
.Modifier and Type | Field and Description |
---|---|
static char |
VALUE_SEPERATOR
The character use to seperate the X and Y value when making a to string representation or decoding a string representation.
|
Constructor and Description |
---|
Point2D()
Default construtor, sets X and Y to 0.
|
Point2D(double x,
double y)
Constructor with doubles.
|
Point2D(int x,
int y)
Constructor with integers (int).
|
Point2D(Point point)
Construct a Point2D using the values from
java.awt.Point . |
Point2D(Point2D.Double point)
Construct a Point2D using the values from
java.awt.geom.Point2D.Double . |
Modifier and Type | Method and Description |
---|---|
int |
compareTo(Point2D o)
Compares the length of a Point3D
|
double |
distance(Point otherPoint)
The distance between two points.
|
double |
distance(Point2D.Double otherPoint)
The distance between two points.
|
double |
distance(Point2D otherPoint)
The distance between two points.
|
boolean |
equals(Object obj)
Determines if this Point2D is equals with either another Point2D,java.awt.Point or java.awt.geom.Point2D.Double.
|
boolean |
equals(Object obj,
double precision)
Compares an other object with this.
|
LatLng |
getAsLatLng()
Get instance of LatLng where X is latitude and Y is longitude.
|
Point |
getAsPoint()
Converts this Point2D to a
java.awt.Point using the getAsInt methods. |
Point2D.Double |
getAsPoint2DDouble()
Converts this Point2D to a
java.awt.geom.Point2D.Double . |
double |
getLength()
Getting the distance from (0,0) to this point.
|
Point2D |
getUnitVector()
In mathematics, a unit vector in a normed vector space is a vector (often a spatial vector) whose length is 1 (the unit length).
|
Double |
getX()
Gets the X value as a Double
|
int |
getXAsInt()
Gets the X value as an int using
Double.intValue() method. |
Double |
getY()
Gets the Y value as a Double
|
int |
getYAsInt()
Gets the Y value as an int using
Double.intValue() method. |
int |
hashCode() |
Point2D |
scale(double factor)
Scale the values in this Point with factor an returns the result as a new Point.
|
String |
toString() |
Point2D |
translate(double dx,
double dy)
Translates this point, at location (x,y),
by dx along the x axis and dy along the y axis so that it now represents the point (x+dx,y+dy) . |
public static final char VALUE_SEPERATOR
public Point2D()
public Point2D(int x, int y)
x
- the x int.y
- the y int.public Point2D(double x, double y)
x
- the x double.y
- the y double.public Point2D(Point point) throws NullPointerException
java.awt.Point
.point
- the java.awt.PointNullPointerException
- if the Point is null
.Point
public Point2D(Point2D.Double point) throws NullPointerException
java.awt.geom.Point2D.Double
.point
- the java.awt.geom.Point2D.Double.NullPointerException
- if the Point is null
.Point2D.Double
public Double getX()
public Double getY()
public int getXAsInt()
Double.intValue()
method.Double.intValue()
public int getYAsInt()
Double.intValue()
method.Double.intValue()
public Point getAsPoint()
java.awt.Point
using the getAsInt methods.Point
,
getXAsInt()
,
getYAsInt()
public Point2D.Double getAsPoint2DDouble()
java.awt.geom.Point2D.Double
.Point2D.Double
,
Point2D
public LatLng getAsLatLng()
public double getLength()
public double distance(Point2D otherPoint) throws NullPointerException
otherPoint
- the other Point2DNullPointerException
- if the otherPoint is null
.public double distance(Point otherPoint) throws NullPointerException
otherPoint
- the other Point as java.awt.Point.NullPointerException
- if the otherPoint is null
.public double distance(Point2D.Double otherPoint) throws NullPointerException
otherPoint
- the other Point as java.awt.geom.Point2D.Double.NullPointerException
- if the otherPoint is null
.public Point2D scale(double factor)
factor
- the factor the scale the values with.public Point2D translate(double dx, double dy)
(x+dx,y+dy)
.dx
- the distance to move this point along the X axisdy
- the distance to move this point along the Y axisnew Point2D(x+dx,y+dy)
.public Point2D getUnitVector()
public boolean equals(Object obj)
equals
in class Object
equals(Object, double)
,
{@inheritDoc}
public boolean equals(Object obj, double precision)
obj
- the other objectprecision
- the precesion at shall compare the doubles values with.false
if obj
is null
or not of type (Point2D, java.awt.Point or java.awt.geom.Point2D.Double). Otherwise it compare the values from Point2D, java.awt.Point or java.awt.geom.Point2D.Double.public int compareTo(Point2D o)
compareTo
in interface Comparable<Point2D>