Module org.dyn4j

Class CircleDetector


  • public final class CircleDetector
    extends Object
    Class devoted to Circle detection queries.
    Since:
    2.0.0
    Version:
    4.2.1
    Author:
    William Bittle
    • Method Detail

      • detect

        public static final boolean detect​(Circle circle1,
                                           Transform transform1,
                                           Circle circle2,
                                           Transform transform2,
                                           Penetration penetration)
        Fast method for determining a collision between two Circles.

        Returns true if the given Circles are intersecting and places the penetration vector and depth in the given Penetration object.

        If the Circle centers are coincident then the penetration Vector2 will be the zero Vector2, however, the penetration depth will be correct. In this case its up to the caller to determine a reasonable penetration Vector2.

        NOTE: It's the responsibility of the caller to clear the given Penetration object before calling this method.

        Parameters:
        circle1 - the first Circle
        transform1 - the first Circle's Transform
        circle2 - the second Circle
        transform2 - the second Circle's Transform
        penetration - the Penetration object to fill
        Returns:
        boolean
      • detect

        public static final boolean detect​(Circle circle1,
                                           Transform transform1,
                                           Circle circle2,
                                           Transform transform2)
        Fast method for determining a collision between two Circles.

        Returns true if the given Circles are intersecting.

        Parameters:
        circle1 - the first Circle
        transform1 - the first Circle's Transform
        circle2 - the second Circle
        transform2 - the second Circle's Transform
        Returns:
        boolean true if the two circles intersect
      • distance

        public static final boolean distance​(Circle circle1,
                                             Transform transform1,
                                             Circle circle2,
                                             Transform transform2,
                                             Separation separation)
        Fast method for determining the distance between two Circles.

        Returns true if the given Circles are separated and places the separating vector and distance in the given Separation object.

        NOTE: It's the responsibility of the caller to clear the given Separation object before calling this method.

        Parameters:
        circle1 - the first Circle
        transform1 - the first Circle's Transform
        circle2 - the second Circle
        transform2 - the second Circle's Transform
        separation - the Separation object to fill
        Returns:
        boolean
      • contains

        public static final boolean contains​(Circle circle1,
                                             Transform transform1,
                                             Circle circle2,
                                             Transform transform2,
                                             Containment containment)
        Fast method for determining whether one circle is contained in another Circles.

        Returns true if one of the Circles is contained in the other and places the result in the given Containment object.

        NOTE: It's the responsibility of the caller to clear the given Containment object before calling this method.

        Parameters:
        circle1 - the first Circle
        transform1 - the first Circle's Transform
        circle2 - the second Circle
        transform2 - the second Circle's Transform
        containment - the Containment object to fill
        Returns:
        boolean
        Since:
        4.2.1
      • raycast

        public static final boolean raycast​(Ray ray,
                                            double maxLength,
                                            Circle circle,
                                            Transform transform,
                                            Raycast raycast)
        Performs a ray cast against the given circle.

        Returns true if the given Ray intersects with the given Circle and places the result in the given Raycast object.

        NOTE: It's the responsibility of the caller to clear the given Raycast object before calling this method.

        Parameters:
        ray - the Ray
        maxLength - the maximum ray length
        circle - the Circle
        transform - the Circle's Transform
        raycast - the Raycast result
        Returns:
        boolean true if the ray intersects the circle
        Since:
        2.0.0