Package eu.svjatoslav.sixth.e3d.geometry
Class Point3D
java.lang.Object
eu.svjatoslav.sixth.e3d.geometry.Point3D
- All Implemented Interfaces:
Cloneable
Used to represent point in a 3D space or vector.
- See Also:
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionAdd other point to current point.Add coordinates of current point to other point.clone()
Create new point by cloning position of current point.Copy coordinates from other point to current point.computeMiddlePoint
(Point3D p1, Point3D p2) Set current point coordinates to the middle point between two other points.double
getAngleXY
(Point3D anotherPoint) double
getAngleXZ
(Point3D anotherPoint) double
getAngleYZ
(Point3D anotherPoint) double
getDistanceTo
(Point3D anotherPoint) Compute distance to another point.double
invert()
Invert current point coordinates.boolean
Here we assume that Z coordinate is distance to the viewer.boolean
isZero()
rotate
(double angleXZ, double angleYZ) Rotate current point around center point by angleXZ and angleYZ.void
Round current point coordinates to integer values.scaleDown
(double factor) Scale down current point by factor.scaleUp
(double factor) Scale up current point by factor.void
setValues
(double x, double y, double z) Set current point coordinates to given values.Subtract other point from current point.toString()
translateX
(double xIncrement) Translate current point along X axis by given increment.translateY
(double yIncrement) Translate current point along Y axis by given increment.translateZ
(double zIncrement) Translate current point along Z axis by given increment.zero()
Resets point coordinates to zero along all axes.
-
Field Details
-
x
public double x -
y
public double y -
z
public double z
-
-
Constructor Details
-
Point3D
public Point3D() -
Point3D
public Point3D(double x, double y, double z) -
Point3D
public Point3D(float x, float y, float z) -
Point3D
public Point3D(int x, int y, int z) -
Point3D
-
Point3D
Creates new current point by cloning coordinates from parent point.
-
-
Method Details
-
add
Add other point to current point. Value of other point will not be changed.- Parameters:
otherPoint
- point to add.- Returns:
- current point.
-
addTo
Add coordinates of current point to other point. Value of current point will not be changed.- Returns:
- current point.
-
clone
Create new point by cloning position of current point. -
clone
Copy coordinates from other point to current point. Value of other point will not be changed. -
computeMiddlePoint
Set current point coordinates to the middle point between two other points.- Parameters:
p1
- first point.p2
- second point.- Returns:
- current point.
-
isZero
public boolean isZero()- Returns:
- true if current point coordinates are equal to zero.
-
getAngleXZ
-
getAngleYZ
-
getAngleXY
-
getDistanceTo
Compute distance to another point.- Parameters:
anotherPoint
- point to compute distance to.- Returns:
- distance to another point.
-
getVectorLength
public double getVectorLength()- Returns:
- length of current vector.
-
invert
Invert current point coordinates.- Returns:
- current point.
-
rotate
Rotate current point around center point by angleXZ and angleYZ.- Parameters:
center
- center point.angleXZ
- angle around XZ axis.angleYZ
- angle around YZ axis.
-
rotate
-
roundToInteger
public void roundToInteger()Round current point coordinates to integer values. -
scaleDown
Scale down current point by factor. All coordinates will be divided by factor.- Parameters:
factor
- factor to scale by.- Returns:
- current point.
-
scaleUp
Scale up current point by factor. All coordinates will be multiplied by factor.- Parameters:
factor
- factor to scale by.- Returns:
- current point.
-
setValues
public void setValues(double x, double y, double z) Set current point coordinates to given values.- Parameters:
x
- X coordinate.y
- Y coordinate.z
- Z coordinate.
-
subtract
Subtract other point from current point. Value of other point will not be changed.- Returns:
- current point.
-
toString
-
translateX
Translate current point along X axis by given increment.- Returns:
- current point.
-
translateY
Translate current point along Y axis by given increment.- Returns:
- current point.
-
translateZ
Translate current point along Z axis by given increment.- Returns:
- current point.
-
isVisible
public boolean isVisible()Here we assume that Z coordinate is distance to the viewer. If Z is positive, then point is in front of the viewer, and therefore it is visible.- Returns:
- point visibility status.
-
zero
Resets point coordinates to zero along all axes.- Returns:
- current point.
-