Package eu.svjatoslav.sixth.e3d.geometry
Class Point2D
java.lang.Object
eu.svjatoslav.sixth.e3d.geometry.Point2D
- All Implemented Interfaces:
Cloneable
Used to represent point in a 2D space or vector.
- See Also:
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionAdd other point to current point.clone()
void
Copy coordinates from other point to current point.double
getAngleXY
(Point2D anotherPoint) double
getDistanceTo
(Point2D anotherPoint) Compute distance to another point.double
Calculate length of vector.invert()
Invert current point.boolean
isZero()
void
Round current point coordinates to integer.setToMiddle
(Point2D p1, Point2D p2) Set current point to middle of two other points.Subtract other point from current point.to3D()
Convert current point to 3D point.toString()
zero()
Set current point to zero.
-
Field Details
-
x
public double x -
y
public double y
-
-
Constructor Details
-
Point2D
public Point2D() -
Point2D
public Point2D(double x, double y) -
Point2D
-
-
Method Details
-
add
Add other point to current point. Value of other point will not be changed.- Returns:
- current point.
-
isZero
public boolean isZero()- Returns:
- true if current point coordinates are equal to zero.
-
clone
-
clone
Copy coordinates from other point to current point. Value of other point will not be changed. -
setToMiddle
Set current point to middle of two other points.- Parameters:
p1
- first point.p2
- second point.- Returns:
- current point.
-
getAngleXY
-
getDistanceTo
Compute distance to another point.- Parameters:
anotherPoint
- point to compute distance to.- Returns:
- distance from current point to another point.
-
getVectorLength
public double getVectorLength()Calculate length of vector.- Returns:
- length of vector.
-
invert
Invert current point.- Returns:
- current point.
-
roundToInteger
public void roundToInteger()Round current point coordinates to integer. -
subtract
Subtract other point from current point. Value of other point will not be changed.- Returns:
- current point.
-
to3D
Convert current point to 3D point. Value of the z coordinate will be set to zero.- Returns:
- 3D point.
-
zero
Set current point to zero.- Returns:
- current point.
-
toString
-