Module org.dyn4j

Class Circle

    • Constructor Detail

      • Circle

        public Circle​(double radius)
        Full constructor.

        Creates a new Circle centered on the origin with the given radius.

        Parameters:
        radius - the radius
        Throws:
        java.lang.IllegalArgumentException - if the given radius is less than or equal to zero
    • Method Detail

      • getRadius

        public double getRadius​(Vector2 center)
        Description copied from interface: Shape
        Returns the radius of the shape if the given point was the center for this shape.
        Specified by:
        getRadius in interface Shape
        Parameters:
        center - the center point
        Returns:
        double
      • contains

        public boolean contains​(Vector2 point,
                                Transform transform)
        Description copied from interface: Shape
        Returns true if the given point is inside this Shape.

        If the given point lies on an edge the point is considered to be inside the Shape.

        The given point is assumed to be in world space.

        Specified by:
        contains in interface Shape
        Parameters:
        point - world space point
        transform - Transform for this Shape
        Returns:
        boolean
      • getFarthestPoint

        public Vector2 getFarthestPoint​(Vector2 vector,
                                        Transform transform)
        Description copied from interface: Convex
        Returns the point farthest in the direction of the given vector. If two points are equally distant along the given Vector2 the first one is used.

        The returned point is in world space.

        Specified by:
        getFarthestPoint in interface Convex
        Parameters:
        vector - the direction
        transform - the local to world space Transform of this Convex Shape
        Returns:
        Vector2
      • getAxes

        public Vector2[] getAxes​(Vector2[] foci,
                                 Transform transform)
        Returns an array of separating axes to test for this Shape.

        The foci parameter is an array of circular focal points of the other Shape.

        If foci points are given, this method will return the separating axes for this Shape's voronoi regions also. The points in the foci array are assumed to be in world space.

        The returned axes are normalized and in world space.

        Circular shapes are handled specifically in the SAT algorithm since they have an infinite number of axes. As a result this method returns null.

        Specified by:
        getAxes in interface Convex
        Parameters:
        foci - the world space points representing foci of curved Shapes; can be null
        transform - the local to world space Transform of this Convex Shape
        Returns:
        null
      • getFoci

        public Vector2[] getFoci​(Transform transform)
        Description copied from interface: Convex
        Returns an array of world space foci points for circular curved edges.

        This method returns null if the Shape has zero curved edges.

        The returned points are in world space.

        Specified by:
        getFoci in interface Convex
        Parameters:
        transform - the local to world space Transform of this Convex Shape
        Returns:
        Vector2[]
      • createMass

        public Mass createMass​(double density)
        Creates a Mass object using the geometric properties of this Shape and the given density.

        m = d * π * r2 I = m * r2 / 2

        Specified by:
        createMass in interface Shape
        Parameters:
        density - the density in kg/m2
        Returns:
        Mass the Mass of this Shape