Class GridPoint3

  • All Implemented Interfaces:
    java.io.Serializable

    public class GridPoint3
    extends java.lang.Object
    implements java.io.Serializable
    A point in a 3D grid, with integer x and y coordinates
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      int x  
      int y  
      int z  
    • Constructor Summary

      Constructors 
      Constructor Description
      GridPoint3()
      Constructs a 3D grid point with all coordinates pointing to the origin (0, 0, 0).
      GridPoint3​(int x, int y, int z)
      Constructs a 3D grid point.
      GridPoint3​(GridPoint3 point)
      Copy constructor
    • Field Detail

      • x

        public int x
      • y

        public int y
      • z

        public int z
    • Constructor Detail

      • GridPoint3

        public GridPoint3()
        Constructs a 3D grid point with all coordinates pointing to the origin (0, 0, 0).
      • GridPoint3

        public GridPoint3​(int x,
                          int y,
                          int z)
        Constructs a 3D grid point.
        Parameters:
        x - X coordinate
        y - Y coordinate
        z - Z coordinate
      • GridPoint3

        public GridPoint3​(GridPoint3 point)
        Copy constructor
        Parameters:
        point - The 3D grid point to make a copy of.
    • Method Detail

      • set

        public GridPoint3 set​(GridPoint3 point)
        Sets the coordinates of this 3D grid point to that of another.
        Parameters:
        point - The 3D grid point to copy coordinates of.
        Returns:
        this GridPoint3 for chaining.
      • set

        public GridPoint3 set​(int x,
                              int y,
                              int z)
        Sets the coordinates of this GridPoint3D.
        Parameters:
        x - X coordinate
        y - Y coordinate
        z - Z coordinate
        Returns:
        this GridPoint3D for chaining.
      • dst2

        public float dst2​(GridPoint3 other)
        Parameters:
        other - The other point
        Returns:
        the squared distance between this point and the other point.
      • dst2

        public float dst2​(int x,
                          int y,
                          int z)
        Parameters:
        x - The x-coordinate of the other point
        y - The y-coordinate of the other point
        z - The z-coordinate of the other point
        Returns:
        the squared distance between this point and the other point.
      • dst

        public float dst​(GridPoint3 other)
        Parameters:
        other - The other point
        Returns:
        the distance between this point and the other vector.
      • dst

        public float dst​(int x,
                         int y,
                         int z)
        Parameters:
        x - The x-coordinate of the other point
        y - The y-coordinate of the other point
        z - The z-coordinate of the other point
        Returns:
        the distance between this point and the other point.
      • add

        public GridPoint3 add​(GridPoint3 other)
        Adds another 3D grid point to this point.
        Parameters:
        other - The other point
        Returns:
        this 3d grid point for chaining.
      • add

        public GridPoint3 add​(int x,
                              int y,
                              int z)
        Adds another 3D grid point to this point.
        Parameters:
        x - The x-coordinate of the other point
        y - The y-coordinate of the other point
        z - The z-coordinate of the other point
        Returns:
        this 3d grid point for chaining.
      • sub

        public GridPoint3 sub​(GridPoint3 other)
        Subtracts another 3D grid point from this point.
        Parameters:
        other - The other point
        Returns:
        this 3d grid point for chaining.
      • sub

        public GridPoint3 sub​(int x,
                              int y,
                              int z)
        Subtracts another 3D grid point from this point.
        Parameters:
        x - The x-coordinate of the other point
        y - The y-coordinate of the other point
        z - The z-coordinate of the other point
        Returns:
        this 3d grid point for chaining.
      • cpy

        public GridPoint3 cpy()
        Returns:
        a copy of this grid point
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object