Module org.dyn4j

Interface Collidable<T extends Fixture>

    • Method Detail

      • getId

        @Deprecated
        java.util.UUID getId()
        Deprecated.
        ID schemes should be implemented by the user where needed; since 3.4.0
        Returns a unique identifier for this Collidable.

        This identifier is constant for the life of this Collidable.

        Returns:
        UUID the unique id
        Since:
        3.0.0
      • createAABB

        AABB createAABB()
        Creates an AABB from this Collidable's attached Fixtures.

        If there are no fixtures attached, a degenerate AABB, (0.0, 0.0) to (0.0, 0.0), is returned.

        Returns:
        AABB
        Since:
        3.0.0
      • createAABB

        AABB createAABB​(Transform transform)
        Creates an AABB from this Collidable's attached Fixtures using the given world space Transform.

        If there are no fixtures attached, a degenerate AABB, (0.0, 0.0) to (0.0, 0.0), is returned.

        Parameters:
        transform - the world space Transform
        Returns:
        AABB
        Throws:
        java.lang.NullPointerException - if the given transform is null
        Since:
        3.2.0
      • addFixture

        Collidable<T> addFixture​(T fixture)
        Adds the given Fixture to this Collidable.
        Parameters:
        fixture - the Fixture to add
        Returns:
        Collidable this collidable
        Throws:
        java.lang.NullPointerException - if fixture is null
        Since:
        3.2.0
      • addFixture

        T addFixture​(Convex convex)
        Creates a Fixture for the given Convex Shape, adds it to this Collidable, and returns it.
        Parameters:
        convex - the Convex Shape to add
        Returns:
        T the fixture created
        Throws:
        java.lang.NullPointerException - if convex is null
        Since:
        3.2.0
      • getFixture

        T getFixture​(int index)
        Returns the Fixture at the given index.
        Parameters:
        index - the index of the Fixture
        Returns:
        T the fixture
        Throws:
        java.lang.IndexOutOfBoundsException - if index is out of bounds
        Since:
        2.0.0
      • containsFixture

        boolean containsFixture​(T fixture)
        Returns true if this Collidable contains the given Fixture.
        Parameters:
        fixture - the fixture
        Returns:
        boolean
        Since:
        3.2.0
      • getFixture

        T getFixture​(Vector2 point)
        Returns the first Fixture in this Collidable, determined by the order in which they were added, that contains the given point.

        Returns null if the point is not contained in any fixture in this Collidable.

        Parameters:
        point - a world space point
        Returns:
        T the fixture or null
        Throws:
        java.lang.NullPointerException - if point is null
        Since:
        3.2.0
      • getFixtures

        java.util.List<T> getFixtures​(Vector2 point)
        Returns all the Fixtures in this Collidable that contain the given point.

        Returns an empty list if the point is not contained in any fixture in this Collidable.

        Parameters:
        point - a world space point
        Returns:
        List<T>
        Throws:
        java.lang.NullPointerException - if point is null
        Since:
        3.2.0
      • removeFixture

        boolean removeFixture​(T fixture)
        Removes the given Fixture from this Collidable.
        Parameters:
        fixture - the Fixture
        Returns:
        boolean true if the Fixture was removed from this Collidable
        Since:
        3.2.0
      • removeFixture

        T removeFixture​(int index)
        Removes the Fixture at the given index.
        Parameters:
        index - the index
        Returns:
        T the fixture removed
        Throws:
        java.lang.IndexOutOfBoundsException - if index is out of bounds
        Since:
        3.2.0
      • removeAllFixtures

        java.util.List<T> removeAllFixtures()
        Removes all fixtures from this Collidable and returns them.
        Returns:
        List<T>
        Since:
        3.2.0
      • removeFixture

        T removeFixture​(Vector2 point)
        Removes the first Fixture in this Collidable, determined by the order in which they were added, that contains the given point and returns it.

        Returns null if the point is not contained in any Fixture in this Collidable.

        Parameters:
        point - a world space point
        Returns:
        T the fixture or null
        Throws:
        java.lang.NullPointerException - if point is null
        Since:
        3.2.0
      • removeFixtures

        java.util.List<T> removeFixtures​(Vector2 point)
        Removes all the Fixtures in this Collidable that contain the given point and returns them.

        Returns an empty list if the point is not contained in any Fixture in this Collidable.

        Parameters:
        point - a world space point
        Returns:
        List<T>
        Throws:
        java.lang.NullPointerException - if point is null
        Since:
        3.2.0
      • getFixtureCount

        int getFixtureCount()
        Returns the number of Fixtures attached to this Collidable object.
        Returns:
        int
        Since:
        2.0.0
      • getFixtures

        java.util.List<T> getFixtures()
        Returns an unmodifiable list containing the Fixtures attached to this Collidable.

        The returned list is backed by the internal list, therefore adding or removing fixtures while iterating through the returned list is not permitted. Use the getFixtureIterator() method instead.

        Returns:
        List<T>
        Since:
        3.1.5
        See Also:
        getFixtureIterator()
      • getFixtureIterator

        java.util.Iterator<T> getFixtureIterator()
        Returns an iterator for this collidable's fixtures.

        The returned iterator supports the remove method.

        Returns:
        Iterator<T>
        Since:
        3.2.0
      • contains

        boolean contains​(Vector2 point)
        Returns true if the given world space point is contained in this Collidable.

        The point is contained in this Collidable if and only if the point is contained in one of this Collidable's Fixtures.

        Parameters:
        point - the world space test point
        Returns:
        boolean
        Throws:
        java.lang.NullPointerException - if point is null
        Since:
        3.2.0
      • getLocalCenter

        Vector2 getLocalCenter()
        Returns the center for this Collidable in local coordinates.
        Returns:
        Vector2 the center in local coordinates
        Since:
        3.2.0
      • getWorldCenter

        Vector2 getWorldCenter()
        Returns the center for this Collidable in world coordinates.
        Returns:
        Vector2 the center in world coordinates
        Since:
        3.2.0
      • getLocalPoint

        Vector2 getLocalPoint​(Vector2 worldPoint)
        Returns a new point in local coordinates of this Collidable given a point in world coordinates.
        Parameters:
        worldPoint - a world space point
        Returns:
        Vector2 local space point
        Throws:
        java.lang.NullPointerException - if the given point is null
        Since:
        3.2.0
      • getWorldPoint

        Vector2 getWorldPoint​(Vector2 localPoint)
        Returns a new point in world coordinates given a point in the local coordinates of this Collidable.
        Parameters:
        localPoint - a point in the local coordinates of this Collidable
        Returns:
        Vector2 world space point
        Throws:
        java.lang.NullPointerException - if the given point is null
        Since:
        3.2.0
      • getLocalVector

        Vector2 getLocalVector​(Vector2 worldVector)
        Returns a new vector in local coordinates of this Collidable given a vector in world coordinates.
        Parameters:
        worldVector - a world space vector
        Returns:
        Vector2 local space vector
        Throws:
        java.lang.NullPointerException - if the given vector is null
        Since:
        3.2.0
      • getWorldVector

        Vector2 getWorldVector​(Vector2 localVector)
        Returns a new vector in world coordinates given a vector in the local coordinates of this Collidable.
        Parameters:
        localVector - a vector in the local coordinates of this Collidable
        Returns:
        Vector2 world space vector
        Throws:
        java.lang.NullPointerException - if the given vector is null
        Since:
        3.2.0
      • getRotationDiscRadius

        double getRotationDiscRadius()
        Returns the maximum radius of the disk that the Collidable creates if rotated 360 degrees about its center.
        Returns:
        double the maximum radius of the rotation disk
      • setTransform

        void setTransform​(Transform transform)
        Sets this Collidable's local to world space Transform.

        If the given transform is null, this method returns immediately.

        Parameters:
        transform - the transform
        Since:
        3.2.0
      • rotateAboutCenter

        void rotateAboutCenter​(double theta)
        Rotates the Collidable about its center.
        Parameters:
        theta - the angle of rotation in radians
      • translateToOrigin

        void translateToOrigin()
        Translates the center of the Collidable to the world space origin (0,0).

        This method is useful if bodies have a number of fixtures and the center is not at the origin. This method will reposition this Collidable so that the center is at the origin.

        Since:
        3.2.0