Module gomint.api

Class AxisAlignedBB

  • All Implemented Interfaces:
    Cloneable

    public class AxisAlignedBB
    extends Object
    implements Cloneable
    Version:
    1.0
    Author:
    geNAZt
    • Constructor Detail

      • AxisAlignedBB

        public AxisAlignedBB​(float minX,
                             float minY,
                             float minZ,
                             float maxX,
                             float maxY,
                             float maxZ)
        Construct a new BoundingBox with the min and max coordinates given
        Parameters:
        minX - Minimum X Coordinate
        minY - Minimum Y Coordinate
        minZ - Minimum Z Coordinate
        maxX - Maximum X Coordinate
        maxY - Maximum Y Coordinate
        maxZ - Maximum Z Coordinate
    • Method Detail

      • setBounds

        public AxisAlignedBB setBounds​(float minX,
                                       float minY,
                                       float minZ,
                                       float maxX,
                                       float maxY,
                                       float maxZ)
        Set new bounds
        Parameters:
        minX - Minimum X Coordinate
        minY - Minimum Y Coordinate
        minZ - Minimum Z Coordinate
        maxX - Maximum X Coordinate
        maxY - Maximum Y Coordinate
        maxZ - Maximum Z Coordinate
        Returns:
        the Bounding Box with new bounds
      • setBounds

        public AxisAlignedBB setBounds​(AxisAlignedBB other)
        Set new bounds
        Parameters:
        other - the other Bounding Box from which we should copy
        Returns:
        the Bounding Box with new bounds
      • addCoordinates

        public AxisAlignedBB addCoordinates​(float x,
                                            float y,
                                            float z)
        Add coordinates to the Bounding Box
        Parameters:
        x - the X coordinate which should be added
        y - the Y coordinate which should be added
        z - the Z coordinate which should be added
        Returns:
        a new Bounding Box which contains the addition of the coordinates
      • grow

        public AxisAlignedBB grow​(float x,
                                  float y,
                                  float z)
        Grow the Bounding Box and return a new one
        Parameters:
        x - the X coordinate to grow in both directions
        y - the Y coordinate to grow in both directions
        z - the Z coordinate to grow in both directions
        Returns:
        a new Bounding Box which has been grown by the amount given
      • expand

        public AxisAlignedBB expand​(float x,
                                    float y,
                                    float z)
        Expand this Bounding Box by the given coordinates
        Parameters:
        x - the X coordinate to expand in both directions
        y - the Y coordinate to expand in both directions
        z - the Z coordinate to expand in both directions
        Returns:
        this modified Bounding Box
      • offset

        public AxisAlignedBB offset​(float x,
                                    float y,
                                    float z)
        Offset the Bounding Box by the given coordinates
        Parameters:
        x - the X coordinate for how much we should offset
        y - the Y coordinate for how much we should offset
        z - the Z coordinate for how much we should offset
        Returns:
        this modified Bounding Box
      • shrink

        public AxisAlignedBB shrink​(float x,
                                    float y,
                                    float z)
        Shrink the Bounding Box and return a new one
        Parameters:
        x - the X coordinate to shrink in both directions
        y - the Y coordinate to shrink in both directions
        z - the Z coordinate to shrink in both directions
        Returns:
        a new Bounding Box which has been grown by the amount given
      • contract

        public AxisAlignedBB contract​(float x,
                                      float y,
                                      float z)
        Contract this Bounding Box by the given coordinates
        Parameters:
        x - the X coordinate to contract in both directions
        y - the Y coordinate to contract in both directions
        z - the Z coordinate to contract in both directions
        Returns:
        this modified Bounding Box
      • getOffsetBoundingBox

        public AxisAlignedBB getOffsetBoundingBox​(float x,
                                                  float y,
                                                  float z)
        Offset the Bounding Box by the given coordinates and return a new one
        Parameters:
        x - the X coordinate for how much we should offset
        y - the Y coordinate for how much we should offset
        z - the Z coordinate for how much we should offset
        Returns:
        a new Bounding Box which has been offset
      • calculateXOffset

        public float calculateXOffset​(AxisAlignedBB bb,
                                      float x)
        Get the offset in x axis
        Parameters:
        bb - the bounding box from which we want to know the offset to
        x - default or maximum offset allowed
        Returns:
        offset or capped value
      • calculateYOffset

        public float calculateYOffset​(AxisAlignedBB bb,
                                      float y)
        Get the offset in y axis
        Parameters:
        bb - the bounding box from which we want to know the offset to
        y - default or maximum offset allowed
        Returns:
        offset or capped value
      • calculateZOffset

        public float calculateZOffset​(AxisAlignedBB bb,
                                      float z)
        Get the offset in z axis
        Parameters:
        bb - the bounding box from which we want to know the offset to
        z - default or maximum offset allowed
        Returns:
        offset or capped value
      • intersectsWith

        public boolean intersectsWith​(AxisAlignedBB bb)
        Check if we intersect with the given Bounding Box
        Parameters:
        bb - the other bounding box we want to check for intersection with
        Returns:
        true when the given Bounding Box intersects with this one, false when not
      • isVectorInside

        public boolean isVectorInside​(Vector vector)
        Check if the given Vector lies within this Bounding Box
        Parameters:
        vector - the vector which may or may not be in this Bounding Box
        Returns:
        true when the vector is inside this Bounding Box, false when not
      • getAverageEdgeLength

        public float getAverageEdgeLength()
        Get the average edge length of this Bounding Box
        Returns:
        the average edge length
      • isVectorInYZ

        public boolean isVectorInYZ​(Vector vector)
      • isVectorInXZ

        public boolean isVectorInXZ​(Vector vector)
      • isVectorInXY

        public boolean isVectorInXY​(Vector vector)
      • calculateIntercept

        public Vector calculateIntercept​(Vector pos1,
                                         Vector pos2)
        Calculate the vector which is in line with this bounding box.

        |---------x----------| pos1 this bb pos2

        Parameters:
        pos1 - from the start
        pos2 - from the end
        Returns:
        null when not on line or vector we found