Class Point3D

java.lang.Object
eu.svjatoslav.sixth.e3d.geometry.Point3D
All Implemented Interfaces:
Cloneable

public class Point3D extends Object implements Cloneable
Used to represent point in a 3D space or vector.
See Also:
  • 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

      public Point3D(IntegerPoint point)
    • Point3D

      public Point3D(Point3D parent)
      Creates new current point by cloning coordinates from parent point.
  • Method Details

    • add

      public Point3D add(Point3D otherPoint)
      Add other point to current point. Value of other point will not be changed.
      Parameters:
      otherPoint - point to add.
      Returns:
      current point.
    • addTo

      public Point3D addTo(Point3D... otherPoints)
      Add coordinates of current point to other point. Value of current point will not be changed.
      Returns:
      current point.
    • clone

      public Point3D clone()
      Create new point by cloning position of current point.
      Overrides:
      clone in class Object
      Returns:
      newly created clone.
    • clone

      public Point3D clone(Point3D otherPoint)
      Copy coordinates from other point to current point. Value of other point will not be changed.
    • computeMiddlePoint

      public Point3D computeMiddlePoint(Point3D p1, Point3D p2)
      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

      public double getAngleXZ(Point3D anotherPoint)
    • getAngleYZ

      public double getAngleYZ(Point3D anotherPoint)
    • getAngleXY

      public double getAngleXY(Point3D anotherPoint)
    • getDistanceTo

      public double getDistanceTo(Point3D anotherPoint)
      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

      public Point3D invert()
      Invert current point coordinates.
      Returns:
      current point.
    • rotate

      public Point3D rotate(Point3D center, double angleXZ, double angleYZ)
      Rotate current point around center point by angleXZ and angleYZ.

      See also: Let's remove Quaternions from every 3D Engine

      Parameters:
      center - center point.
      angleXZ - angle around XZ axis.
      angleYZ - angle around YZ axis.
    • rotate

      public Point3D rotate(double angleXZ, double angleYZ)
    • roundToInteger

      public void roundToInteger()
      Round current point coordinates to integer values.
    • scaleDown

      public Point3D scaleDown(double factor)
      Scale down current point by factor. All coordinates will be divided by factor.
      Parameters:
      factor - factor to scale by.
      Returns:
      current point.
    • scaleUp

      public Point3D scaleUp(double factor)
      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

      public Point3D subtract(Point3D otherPoint)
      Subtract other point from current point. Value of other point will not be changed.
      Returns:
      current point.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • translateX

      public Point3D translateX(double xIncrement)
      Translate current point along X axis by given increment.
      Returns:
      current point.
    • translateY

      public Point3D translateY(double yIncrement)
      Translate current point along Y axis by given increment.
      Returns:
      current point.
    • translateZ

      public Point3D translateZ(double zIncrement)
      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

      public Point3D zero()
      Resets point coordinates to zero along all axes.
      Returns:
      current point.