Module org.dyn4j

Class AbstractShape

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected Vector2 center
      The center of this Shape
      protected java.util.UUID id
      The shape's unique identifier
      protected double radius
      The maximum radius
      protected java.lang.Object userData
      Custom user data object
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected AbstractShape​(double radius)
      Minimal constructor.
      protected AbstractShape​(Vector2 center, double radius)
      Full constructor.
    • Field Detail

      • id

        protected final java.util.UUID id
        The shape's unique identifier
      • radius

        protected double radius
        The maximum radius
      • userData

        protected java.lang.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:
        java.lang.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:
        java.lang.IllegalArgumentException - if radius is zero or less
        java.lang.NullPointerException - if center is null
    • Method Detail

      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getId

        @Deprecated
        public java.util.UUID getId()
        Deprecated.
        Description copied from interface: Shape
        Returns the unique identifier for this shape instance.
        Specified by:
        getId in interface Shape
        Returns:
        UUID
      • 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 java.lang.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​(java.lang.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