Module org.dyn4j

Class AbstractShape

    • Field Detail

      • radius

        protected double radius
        The maximum radius
      • userData

        protected Object userData
        Custom user data object
    • Constructor Detail

      • AbstractShape

        protected AbstractShape​(double radius)
        Minimal constructor.
        Parameters:
        radius - the rotation radius; must be greater than zero
        Throws:
        IllegalArgumentException - if radius is zero or less
      • AbstractShape

        protected AbstractShape​(Vector2 center,
                                double radius)
        Full constructor.
        Parameters:
        center - the center
        radius - the rotation radius; must be greater than zero
        Throws:
        IllegalArgumentException - if radius is zero or less
        NullPointerException - if center is null
    • Method Detail

      • getCenter

        public Vector2 getCenter()
        Description copied from interface: Shape
        Returns the center/centroid of the Shape in local coordinates.
        Specified by:
        getCenter in interface Shape
        Returns:
        Vector2
      • getRadius

        public double getRadius()
        Description copied from interface: Shape
        Returns the maximum radius of the shape from the center.
        Specified by:
        getRadius in interface Shape
        Returns:
        double
      • getUserData

        public Object getUserData()
        Description copied from interface: DataContainer
        Gets the custom user data.
        Specified by:
        getUserData in interface DataContainer
        Returns:
        Object will return null if not set
      • setUserData

        public void setUserData​(Object userData)
        Description copied from interface: DataContainer
        Sets the custom user data to the given data.
        Specified by:
        setUserData in interface DataContainer
        Parameters:
        userData - the user data
      • rotate

        public void rotate​(double theta)
        Description copied from interface: Rotatable
        Rotates the object about the origin.
        Specified by:
        rotate in interface Rotatable
        Parameters:
        theta - the angle of rotation in radians
      • rotate

        public void rotate​(Rotation rotation)
        Description copied from interface: Rotatable
        Rotates the object about the origin.
        Specified by:
        rotate in interface Rotatable
        Parameters:
        rotation - the Rotation representing the rotation amount
      • rotateAboutCenter

        public void rotateAboutCenter​(double theta)
        Description copied from interface: Shape
        Rotates the Shape about it's center.

        This method replaced the overriding functionality of the rotate method from the Transformable interface.

        Specified by:
        rotateAboutCenter in interface Shape
        Parameters:
        theta - the rotation angle in radians
      • rotate

        public void rotate​(double theta,
                           Vector2 point)
        Description copied from interface: Rotatable
        Rotates the object about the given point.
        Specified by:
        rotate in interface Rotatable
        Parameters:
        theta - the angle of rotation in radians
        point - the point to rotate about
      • rotate

        public void rotate​(Rotation rotation,
                           Vector2 point)
        Description copied from interface: Rotatable
        Rotates the object about the given point.
        Specified by:
        rotate in interface Rotatable
        Parameters:
        rotation - the Rotation representing the rotation amount
        point - the point to rotate about
      • rotate

        public void rotate​(double theta,
                           double x,
                           double y)
        Description copied from interface: Rotatable
        Rotates the object about the given coordinates.
        Specified by:
        rotate in interface Rotatable
        Parameters:
        theta - the angle of rotation in radians
        x - the x coordinate to rotate about
        y - the y coordinate to rotate about
      • rotate

        public void rotate​(Rotation rotation,
                           double x,
                           double y)
        Description copied from interface: Rotatable
        Rotates the object about the given point.
        Specified by:
        rotate in interface Rotatable
        Parameters:
        rotation - the Rotation representing the rotation amount
        x - the x coordinate to rotate about
        y - the y coordinate to rotate about
      • translate

        public void translate​(double x,
                              double y)
        Description copied from interface: Translatable
        Translates the object the given amounts in the respective directions.
        Specified by:
        translate in interface Translatable
        Parameters:
        x - the translation in the x direction
        y - the translation in the y direction
      • translate

        public void translate​(Vector2 vector)
        Description copied from interface: Translatable
        Translates the object along the given vector.
        Specified by:
        translate in interface Translatable
        Parameters:
        vector - the translation along a vector
      • contains

        public boolean contains​(Vector2 point)
        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.

        This is the same as calling Shape.contains(Vector2, Transform) and passing a new Transform.

        Specified by:
        contains in interface Shape
        Parameters:
        point - world space point
        Returns:
        boolean