Package org.joml

Class AABBd

    • Field Summary

      Fields 
      Modifier and Type Field Description
      double maxX
      The x coordinate of the maximum corner.
      double maxY
      The y coordinate of the maximum corner.
      double maxZ
      The z coordinate of the maximum corner.
      double minX
      The x coordinate of the minimum corner.
      double minY
      The y coordinate of the minimum corner.
      double minZ
      The z coordinate of the minimum corner.
    • Constructor Summary

      Constructors 
      Constructor Description
      AABBd​()
      Create a new AABBd representing the box with (minX, minY, minZ)=(+inf, +inf, +inf) and (maxX, maxY, maxZ)=(-inf, -inf, -inf).
      AABBd​(double minX, double minY, double minZ, double maxX, double maxY, double maxZ)
      Create a new AABBd with the given minimum and maximum corner coordinates.
      AABBd​(AABBd source)
      Create a new AABBd as a copy of the given source.
      AABBd​(Vector3dc min, Vector3dc max)
      Create a new AABBd with the given minimum and maximum corner coordinates.
      AABBd​(Vector3fc min, Vector3fc max)
      Create a new AABBd with the given minimum and maximum corner coordinates.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      AABBd correctBounds​()
      Ensure that the minimum coordinates are strictly less than or equal to the maximum coordinates by swapping them if necessary.
      boolean equals​(Object obj)  
      double getMax​(int component)
      Get the maximum corner coordinate of the given component.
      double getMin​(int component)
      Get the minimum corner coordinate of the given component.
      int hashCode​()  
      int intersectLineSegment​(double p0X, double p0Y, double p0Z, double p1X, double p1Y, double p1Z, Vector2d result)
      Determine whether the undirected line segment with the end points (p0X, p0Y, p0Z) and (p1X, p1Y, p1Z) intersects this AABB, and return the values of the parameter t in the ray equation p(t) = origin + p0 * (p1 - p0) of the near and far point of intersection.
      int intersectLineSegment​(LineSegmentf lineSegment, Vector2d result)
      Determine whether the given undirected line segment intersects this AABB, and return the values of the parameter t in the ray equation p(t) = origin + p0 * (p1 - p0) of the near and far point of intersection.
      boolean intersectRay​(double originX, double originY, double originZ, double dirX, double dirY, double dirZ, Vector2d result)
      Determine whether the given ray with the origin (originX, originY, originZ) and direction (dirX, dirY, dirZ) intersects this AABB, and return the values of the parameter t in the ray equation p(t) = origin + t * dir of the near and far point of intersection.
      boolean intersectRay​(Rayd ray, Vector2d result)
      Determine whether the given ray intersects this AABB, and return the values of the parameter t in the ray equation p(t) = origin + t * dir of the near and far point of intersection.
      void readExternal​(ObjectInput in)  
      AABBd setMax​(double maxX, double maxY, double maxZ)
      Set the maximum corner coordinates.
      AABBd setMax​(Vector3dc max)
      Set the maximum corner coordinates.
      AABBd setMin​(double minX, double minY, double minZ)
      Set the minimum corner coordinates.
      AABBd setMin​(Vector3dc min)
      Set the minimum corner coordinates.
      boolean testAABB​(AABBd other)
      Test whether this and other intersect.
      boolean testPlane​(double a, double b, double c, double d)
      Test whether the plane given via its plane equation a*x + b*y + c*z + d = 0 intersects this AABB.
      boolean testPlane​(Planed plane)
      Test whether the given plane intersects this AABB.
      boolean testPoint​(double x, double y, double z)
      Test whether the point (x, y, z) lies inside this AABB.
      boolean testPoint​(Vector3dc point)
      Test whether the given point lies inside this AABB.
      boolean testRay​(double originX, double originY, double originZ, double dirX, double dirY, double dirZ)
      Test whether the given ray with the origin (originX, originY, originZ) and direction (dirX, dirY, dirZ) intersects this AABB.
      boolean testRay​(Rayd ray)
      Test whether the given ray intersects this AABB.
      boolean testSphere​(double centerX, double centerY, double centerZ, double radiusSquared)
      Test whether this AABB intersects the given sphere with equation (x - centerX)^2 + (y - centerY)^2 + (z - centerZ)^2 - radiusSquared = 0.
      boolean testSphere​(Spheref sphere)
      Test whether this AABB intersects the given sphere.
      String toString​()
      Return a string representation of this AABB.
      String toString​(NumberFormat formatter)
      Return a string representation of this AABB by formatting the vector components with the given NumberFormat.
      AABBd transform​(Matrix4dc m)
      Apply the given affine transformation to this AABBd.
      AABBd transform​(Matrix4dc m, AABBd dest)
      Apply the given affine transformation to this AABBd and store the resulting AABB into dest.
      AABBd translate​(double x, double y, double z)
      Translate this by the vector (x, y, z).
      AABBd translate​(double x, double y, double z, AABBd dest)
      Translate this by the vector (x, y, z) and store the result in dest.
      AABBd translate​(Vector3dc xyz)
      Translate this by the given vector xyz.
      AABBd translate​(Vector3dc xyz, AABBd dest)
      Translate this by the given vector xyz and store the result in dest.
      AABBd translate​(Vector3fc xyz)
      Translate this by the given vector xyz.
      AABBd translate​(Vector3fc xyz, AABBd dest)
      Translate this by the given vector xyz and store the result in dest.
      AABBd union​(double x, double y, double z)
      Set this to the union of this and the given point (x, y, z).
      AABBd union​(double x, double y, double z, AABBd dest)
      Compute the union of this and the given point (x, y, z) and store the result in dest.
      AABBd union​(AABBd other)
      Set this to the union of this and other.
      AABBd union​(AABBd other, AABBd dest)
      Compute the union of this and other and store the result in dest.
      AABBd union​(Vector3dc p)
      Set this to the union of this and the given point p.
      AABBd union​(Vector3dc p, AABBd dest)
      Compute the union of this and the given point p and store the result in dest.
      void writeExternal​(ObjectOutput out)  
    • Field Detail

      • minX

        public double minX
        The x coordinate of the minimum corner.
      • minY

        public double minY
        The y coordinate of the minimum corner.
      • minZ

        public double minZ
        The z coordinate of the minimum corner.
      • maxX

        public double maxX
        The x coordinate of the maximum corner.
      • maxY

        public double maxY
        The y coordinate of the maximum corner.
      • maxZ

        public double maxZ
        The z coordinate of the maximum corner.
    • Constructor Detail

      • AABBd

        public AABBd​()
        Create a new AABBd representing the box with (minX, minY, minZ)=(+inf, +inf, +inf) and (maxX, maxY, maxZ)=(-inf, -inf, -inf).
      • AABBd

        public AABBd​(AABBd source)
        Create a new AABBd as a copy of the given source.
        Parameters:
        source - the AABBd to copy from
      • AABBd

        public AABBd​(Vector3fc min,
                     Vector3fc max)
        Create a new AABBd with the given minimum and maximum corner coordinates.
        Parameters:
        min - the minimum coordinates
        max - the maximum coordinates
      • AABBd

        public AABBd​(Vector3dc min,
                     Vector3dc max)
        Create a new AABBd with the given minimum and maximum corner coordinates.
        Parameters:
        min - the minimum coordinates
        max - the maximum coordinates
      • AABBd

        public AABBd​(double minX,
                     double minY,
                     double minZ,
                     double maxX,
                     double maxY,
                     double maxZ)
        Create a new AABBd with the given minimum and maximum corner coordinates.
        Parameters:
        minX - the x coordinate of the minimum corner
        minY - the y coordinate of the minimum corner
        minZ - the z coordinate of the minimum corner
        maxX - the x coordinate of the maximum corner
        maxY - the y coordinate of the maximum corner
        maxZ - the z coordinate of the maximum corner
    • Method Detail

      • setMin

        public AABBd setMin​(double minX,
                            double minY,
                            double minZ)
        Set the minimum corner coordinates.
        Parameters:
        minX - the x coordinate of the minimum corner
        minY - the y coordinate of the minimum corner
        minZ - the z coordinate of the minimum corner
        Returns:
        this
      • setMax

        public AABBd setMax​(double maxX,
                            double maxY,
                            double maxZ)
        Set the maximum corner coordinates.
        Parameters:
        maxX - the x coordinate of the maximum corner
        maxY - the y coordinate of the maximum corner
        maxZ - the z coordinate of the maximum corner
        Returns:
        this
      • setMin

        public AABBd setMin​(Vector3dc min)
        Set the minimum corner coordinates.
        Parameters:
        min - the minimum coordinates
        Returns:
        this
      • setMax

        public AABBd setMax​(Vector3dc max)
        Set the maximum corner coordinates.
        Parameters:
        max - the maximum coordinates
        Returns:
        this
      • getMax

        public double getMax​(int component)
                      throws IllegalArgumentException
        Get the maximum corner coordinate of the given component.
        Parameters:
        component - the component, within [0..2]
        Returns:
        the maximum coordinate
        Throws:
        IllegalArgumentException - if component is not within [0..2]
      • getMin

        public double getMin​(int component)
                      throws IllegalArgumentException
        Get the minimum corner coordinate of the given component.
        Parameters:
        component - the component, within [0..2]
        Returns:
        the maximum coordinate
        Throws:
        IllegalArgumentException - if component is not within [0..2]
      • union

        public AABBd union​(double x,
                           double y,
                           double z)
        Set this to the union of this and the given point (x, y, z).
        Parameters:
        x - the x coordinate of the point
        y - the y coordinate of the point
        z - the z coordinate of the point
        Returns:
        this
      • union

        public AABBd union​(Vector3dc p)
        Set this to the union of this and the given point p.
        Parameters:
        p - the point
        Returns:
        this
      • union

        public AABBd union​(double x,
                           double y,
                           double z,
                           AABBd dest)
        Compute the union of this and the given point (x, y, z) and store the result in dest.
        Parameters:
        x - the x coordinate of the point
        y - the y coordinate of the point
        z - the z coordinate of the point
        dest - will hold the result
        Returns:
        dest
      • union

        public AABBd union​(Vector3dc p,
                           AABBd dest)
        Compute the union of this and the given point p and store the result in dest.
        Parameters:
        p - the point
        dest - will hold the result
        Returns:
        dest
      • union

        public AABBd union​(AABBd other)
        Set this to the union of this and other.
        Parameters:
        other - the other AABBd
        Returns:
        this
      • union

        public AABBd union​(AABBd other,
                           AABBd dest)
        Compute the union of this and other and store the result in dest.
        Parameters:
        other - the other AABBd
        dest - will hold the result
        Returns:
        dest
      • correctBounds

        public AABBd correctBounds​()
        Ensure that the minimum coordinates are strictly less than or equal to the maximum coordinates by swapping them if necessary.
        Returns:
        this
      • translate

        public AABBd translate​(Vector3dc xyz)
        Translate this by the given vector xyz.
        Parameters:
        xyz - the vector to translate by
        Returns:
        this
      • translate

        public AABBd translate​(Vector3dc xyz,
                               AABBd dest)
        Translate this by the given vector xyz and store the result in dest.
        Parameters:
        xyz - the vector to translate by
        dest - will hold the result
        Returns:
        dest
      • translate

        public AABBd translate​(Vector3fc xyz)
        Translate this by the given vector xyz.
        Parameters:
        xyz - the vector to translate by
        Returns:
        this
      • translate

        public AABBd translate​(Vector3fc xyz,
                               AABBd dest)
        Translate this by the given vector xyz and store the result in dest.
        Parameters:
        xyz - the vector to translate by
        dest - will hold the result
        Returns:
        dest
      • translate

        public AABBd translate​(double x,
                               double y,
                               double z)
        Translate this by the vector (x, y, z).
        Parameters:
        x - the x coordinate to translate by
        y - the y coordinate to translate by
        z - the z coordinate to translate by
        Returns:
        this
      • translate

        public AABBd translate​(double x,
                               double y,
                               double z,
                               AABBd dest)
        Translate this by the vector (x, y, z) and store the result in dest.
        Parameters:
        x - the x coordinate to translate by
        y - the y coordinate to translate by
        z - the z coordinate to translate by
        dest - will hold the result
        Returns:
        dest
      • testPoint

        public boolean testPoint​(double x,
                                 double y,
                                 double z)
        Test whether the point (x, y, z) lies inside this AABB.
        Parameters:
        x - the x coordinate of the point
        y - the y coordinate of the point
        z - the z coordinate of the point
        Returns:
        true iff the given point lies inside this AABB; false otherwise
      • testPoint

        public boolean testPoint​(Vector3dc point)
        Test whether the given point lies inside this AABB.
        Parameters:
        point - the coordinates of the point
        Returns:
        true iff the given point lies inside this AABB; false otherwise
      • testPlane

        public boolean testPlane​(double a,
                                 double b,
                                 double c,
                                 double d)
        Test whether the plane given via its plane equation a*x + b*y + c*z + d = 0 intersects this AABB.

        Reference: http://www.lighthouse3d.com ("Geometric Approach - Testing Boxes II")

        Parameters:
        a - the x factor in the plane equation
        b - the y factor in the plane equation
        c - the z factor in the plane equation
        d - the constant in the plane equation
        Returns:
        true iff the plane intersects this AABB; false otherwise
      • testPlane

        public boolean testPlane​(Planed plane)
        Test whether the given plane intersects this AABB.

        Reference: http://www.lighthouse3d.com ("Geometric Approach - Testing Boxes II")

        Parameters:
        plane - the plane
        Returns:
        true iff the plane intersects this AABB; false otherwise
      • testAABB

        public boolean testAABB​(AABBd other)
        Test whether this and other intersect.
        Parameters:
        other - the other AABB
        Returns:
        true iff both AABBs intersect; false otherwise
      • testSphere

        public boolean testSphere​(double centerX,
                                  double centerY,
                                  double centerZ,
                                  double radiusSquared)
        Test whether this AABB intersects the given sphere with equation (x - centerX)^2 + (y - centerY)^2 + (z - centerZ)^2 - radiusSquared = 0.

        Reference: http://stackoverflow.com

        Parameters:
        centerX - the x coordinate of the center of the sphere
        centerY - the y coordinate of the center of the sphere
        centerZ - the z coordinate of the center of the sphere
        radiusSquared - the square radius of the sphere
        Returns:
        true iff this AABB and the sphere intersect; false otherwise
      • testSphere

        public boolean testSphere​(Spheref sphere)
        Test whether this AABB intersects the given sphere.

        Reference: http://stackoverflow.com

        Parameters:
        sphere - the sphere
        Returns:
        true iff this AABB and the sphere intersect; false otherwise
      • testRay

        public boolean testRay​(double originX,
                               double originY,
                               double originZ,
                               double dirX,
                               double dirY,
                               double dirZ)
        Test whether the given ray with the origin (originX, originY, originZ) and direction (dirX, dirY, dirZ) intersects this AABB.

        This method returns true for a ray whose origin lies inside this AABB.

        Reference: An Efficient and Robust Ray–Box Intersection

        Parameters:
        originX - the x coordinate of the ray's origin
        originY - the y coordinate of the ray's origin
        originZ - the z coordinate of the ray's origin
        dirX - the x coordinate of the ray's direction
        dirY - the y coordinate of the ray's direction
        dirZ - the z coordinate of the ray's direction
        Returns:
        true if this AABB and the ray intersect; false otherwise
      • testRay

        public boolean testRay​(Rayd ray)
        Test whether the given ray intersects this AABB.

        This method returns true for a ray whose origin lies inside this AABB.

        Reference: An Efficient and Robust Ray–Box Intersection

        Parameters:
        ray - the ray
        Returns:
        true if this AABB and the ray intersect; false otherwise
      • intersectRay

        public boolean intersectRay​(double originX,
                                    double originY,
                                    double originZ,
                                    double dirX,
                                    double dirY,
                                    double dirZ,
                                    Vector2d result)
        Determine whether the given ray with the origin (originX, originY, originZ) and direction (dirX, dirY, dirZ) intersects this AABB, and return the values of the parameter t in the ray equation p(t) = origin + t * dir of the near and far point of intersection.

        This method returns true for a ray whose origin lies inside this AABB.

        Reference: An Efficient and Robust Ray–Box Intersection

        Parameters:
        originX - the x coordinate of the ray's origin
        originY - the y coordinate of the ray's origin
        originZ - the z coordinate of the ray's origin
        dirX - the x coordinate of the ray's direction
        dirY - the y coordinate of the ray's direction
        dirZ - the z coordinate of the ray's direction
        result - a vector which will hold the resulting values of the parameter t in the ray equation p(t) = origin + t * dir of the near and far point of intersection iff the ray intersects this AABB
        Returns:
        true if the given ray intersects this AABB; false otherwise
      • intersectRay

        public boolean intersectRay​(Rayd ray,
                                    Vector2d result)
        Determine whether the given ray intersects this AABB, and return the values of the parameter t in the ray equation p(t) = origin + t * dir of the near and far point of intersection.

        This method returns true for a ray whose origin lies inside this AABB.

        Reference: An Efficient and Robust Ray–Box Intersection

        Parameters:
        ray - the ray
        result - a vector which will hold the resulting values of the parameter t in the ray equation p(t) = origin + t * dir of the near and far point of intersection iff the ray intersects this AABB
        Returns:
        true if the given ray intersects this AABB; false otherwise
      • intersectLineSegment

        public int intersectLineSegment​(double p0X,
                                        double p0Y,
                                        double p0Z,
                                        double p1X,
                                        double p1Y,
                                        double p1Z,
                                        Vector2d result)
        Determine whether the undirected line segment with the end points (p0X, p0Y, p0Z) and (p1X, p1Y, p1Z) intersects this AABB, and return the values of the parameter t in the ray equation p(t) = origin + p0 * (p1 - p0) of the near and far point of intersection.

        This method returns true for a line segment whose either end point lies inside this AABB.

        Reference: An Efficient and Robust Ray–Box Intersection

        Parameters:
        p0X - the x coordinate of the line segment's first end point
        p0Y - the y coordinate of the line segment's first end point
        p0Z - the z coordinate of the line segment's first end point
        p1X - the x coordinate of the line segment's second end point
        p1Y - the y coordinate of the line segment's second end point
        p1Z - the z coordinate of the line segment's second end point
        result - a vector which will hold the resulting values of the parameter t in the ray equation p(t) = p0 + t * (p1 - p0) of the near and far point of intersection iff the line segment intersects this AABB
        Returns:
        Intersectiond.INSIDE if the line segment lies completely inside of this AABB; or Intersectiond.OUTSIDE if the line segment lies completely outside of this AABB; or Intersectiond.ONE_INTERSECTION if one of the end points of the line segment lies inside of this AABB; or Intersectiond.TWO_INTERSECTION if the line segment intersects two sides of this AABB or lies on an edge or a side of this AABB
      • intersectLineSegment

        public int intersectLineSegment​(LineSegmentf lineSegment,
                                        Vector2d result)
        Determine whether the given undirected line segment intersects this AABB, and return the values of the parameter t in the ray equation p(t) = origin + p0 * (p1 - p0) of the near and far point of intersection.

        This method returns true for a line segment whose either end point lies inside this AABB.

        Reference: An Efficient and Robust Ray–Box Intersection

        Parameters:
        lineSegment - the line segment
        result - a vector which will hold the resulting values of the parameter t in the ray equation p(t) = p0 + t * (p1 - p0) of the near and far point of intersection iff the line segment intersects this AABB
        Returns:
        Intersectiond.INSIDE if the line segment lies completely inside of this AABB; or Intersectiond.OUTSIDE if the line segment lies completely outside of this AABB; or Intersectiond.ONE_INTERSECTION if one of the end points of the line segment lies inside of this AABB; or Intersectiond.TWO_INTERSECTION if the line segment intersects two sides of this AABB or lies on an edge or a side of this AABB
      • transform

        public AABBd transform​(Matrix4dc m)
        Apply the given affine transformation to this AABBd.

        The matrix in m must be affine.

        Parameters:
        m - the affine transformation matrix
        Returns:
        this
      • transform

        public AABBd transform​(Matrix4dc m,
                               AABBd dest)
        Apply the given affine transformation to this AABBd and store the resulting AABB into dest.

        The matrix in m must be affine.

        Parameters:
        m - the affine transformation matrix
        dest - will hold the result
        Returns:
        dest
      • hashCode

        public int hashCode​()
        Overrides:
        hashCode in class Object
      • toString

        public String toString​()
        Return a string representation of this AABB.

        This method creates a new DecimalFormat on every invocation with the format string "0.000E0;-".

        Overrides:
        toString in class Object
        Returns:
        the string representation
      • toString

        public String toString​(NumberFormat formatter)
        Return a string representation of this AABB by formatting the vector components with the given NumberFormat.
        Parameters:
        formatter - the NumberFormat used to format the vector components with
        Returns:
        the string representation