Class Point3D


  • public final class Point3D
    extends Object
    Simple class to hold 3d coordinates, immutable.
    Author:
    Gregory Van den Borre
    • Field Detail

      • X_NEGATIVE

        public static final Point3D X_NEGATIVE
      • Y_NEGATIVE

        public static final Point3D Y_NEGATIVE
        Constant with Y = -1.
      • Z_NEGATIVE

        public static final Point3D Z_NEGATIVE
        Constant with Z = -1.
      • X_POSITIVE

        public static final Point3D X_POSITIVE
      • Y_POSITIVE

        public static final Point3D Y_POSITIVE
        Constant with Y = 1.
      • Z_POSITIVE

        public static final Point3D Z_POSITIVE
        Constant with Z = -1.
      • ZERO

        public static final Point3D ZERO
        Constant with all values as 0.
      • BASE_DIRECTION

        public static final Point3D BASE_DIRECTION
        Initial direction for all built object, axis is -Z.
      • x

        public final float x
        Value for the x axis.
      • y

        public final float y
        Value for the y axis.
      • z

        public final float z
        Value for the z axis.
    • Method Detail

      • valueOf

        public static Point3D valueOf​(float x,
                                      float y,
                                      float z)
      • valueOf

        public static Point3D valueOf​(float xyz)
      • valueOfX

        public static Point3D valueOfX​(float x)
      • valueOfY

        public static Point3D valueOfY​(float y)
      • valueOfZ

        public static Point3D valueOfZ​(float z)
      • valueOfXY

        public static Point3D valueOfXY​(float x,
                                        float y)
      • valueOfXY

        public static Point3D valueOfXY​(float xy)
      • valueOfXZ

        public static Point3D valueOfXZ​(float x,
                                        float z)
      • valueOfXZ

        public static Point3D valueOfXZ​(float xz)
      • valueOfYZ

        public static Point3D valueOfYZ​(float y,
                                        float z)
      • valueOfYZ

        public static Point3D valueOfYZ​(float yz)
      • addPoints

        public static Point3D addPoints​(Point3D... points)
        Create a new point from the addition of other points.
        Parameters:
        points - Point3D to add to compute the result.
        Returns:
        A Point3D resulting from the addition of the given points.
      • normalize

        public static Point3D normalize​(Point3D p)
        Normalize a point.
        Parameters:
        p - Point to normalize.
        Returns:
        A new normalized point.
      • normalizeAndMultiply

        public static Point3D normalizeAndMultiply​(Point3D p,
                                                   float scalar)
        Normalize a point and multiply the values.
        Parameters:
        p - Point to normalize.
        scalar - Value to multiply.
        Returns:
        A new point normalized and multiplied.
      • squaredDistance

        public static float squaredDistance​(Point3D p1,
                                            Point3D p2)
        Compute squared distance between 2 points.
        Parameters:
        p1 - First point.
        p2 - Second point.
        Returns:
        The squared distance between the 2 points.
      • add

        public Point3D add​(float x,
                           float y,
                           float z)
        Add values to the values of this point.
        Parameters:
        x - Value to add to this point X value.
        y - Value to add to this point Y value.
        z - Value to add to this point Z value.
        Returns:
        A new point with added values.
      • add

        public Point3D add​(Point3D point)
        Add a point to this one.
        Parameters:
        point - Point to add.
        Returns:
        A new point with added values.
      • addX

        public Point3D addX​(float value)
        Add a value to the X value of this point.
        Parameters:
        value - Value to add to this point X value.
        Returns:
        A new point with added value.
      • addY

        public Point3D addY​(float value)
        Add a value to the Y value of this point.
        Parameters:
        value - value to add to this point Y value.
        Returns:
        A new point with added value.
      • addZ

        public Point3D addZ​(float value)
        Add a value to the Z value of this point.
        Parameters:
        value - value to add to this point Z value.
        Returns:
        A new point with added value.
      • getAngle

        public float getAngle​(Axis axis)
        Get this point angle.
        Parameters:
        axis - Axis to use.
        Returns:
        The point angle.
      • getInverse

        public Point3D getInverse()
        Returns:
        This point with all values inverted(5,10,-8 will be -5,-10,8).
      • multiply

        public Point3D multiply​(float scalar)
        Multiply this point values by a given value.
        Parameters:
        scalar - Value to multiply.
        Returns:
        A new point with the multiplied values.
      • rounded

        public Point3D rounded()
        Returns:
        This point with rounded values.
      • subtract

        public Point3D subtract​(Point3D point)
        Subtract this point values by the other point values.
        Parameters:
        point - Other point to use.
        Returns:
        A new Point3D with the computed values.
      • toXZ

        public Point3D toXZ()
        Returns:
        A copy of this point with 0 as Y coordinate.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object