Module org.dyn4j

Class BodyFixture

    • Field Detail

      • DEFAULT_RESTITUTION_VELOCITY

        public static final double DEFAULT_RESTITUTION_VELOCITY
        The default restitution velocity; in meters/second
        Since:
        4.2.0
        See Also:
        Constant Field Values
      • density

        protected double density
        The density in kg/m2
      • friction

        protected double friction
        The coefficient of friction
      • restitution

        protected double restitution
        The coefficient of restitution
      • restitutionVelocity

        protected double restitutionVelocity
        The minimum velocity to apply restitution
        Since:
        4.2.0
    • Constructor Detail

      • BodyFixture

        public BodyFixture​(Convex shape)
        Minimal constructor.
        Parameters:
        shape - the Convex Shape for this fixture
    • Method Detail

      • setDensity

        public void setDensity​(double density)
        Sets the density of this shape in kg/m2.

        The density of an object is a number that represent how much matter is contained in a given space. Larger density values indicate a more massive object. Larger density objects resist changes in motion more than smaller objects.

        A density equal to zero will make this shape participate in collision detection and resolution, but will it will not contribute to the total mass of the body.

        Parameters:
        density - the density in kg/m2
        Throws:
        IllegalArgumentException - if density is less than zero
      • getDensity

        public double getDensity()
        Returns the density of this shape in kg/m2.
        Returns:
        double the density in kg/m2
        See Also:
        setDensity(double)
      • getFriction

        public double getFriction()
        Returns the coefficient of friction.
        Returns:
        double
        See Also:
        setFriction(double)
      • setFriction

        public void setFriction​(double friction)
        Sets the coefficient of friction.

        The coefficient of friction is a number that represents how rough a material is. Friction between surfaces converts the kinetic (motion) energy into heat, thereby slowing the objects in contact down.

        A higher value of friction will slow the object down faster. A friction value of zero represents no friction.

        Parameters:
        friction - the coefficient of friction; must be greater than zero
        Throws:
        IllegalArgumentException - if friction is less than zero
      • getRestitution

        public double getRestitution()
        Returns the coefficient of restitution.
        Returns:
        double
        See Also:
        setRestitution(double)
      • setRestitution

        public void setRestitution​(double restitution)
        Sets the coefficient of restitution.

        The coefficient of restitution is a number that represents the bounciness of a material. Larger values produce more bounce and smaller values produce less bounce. A value of 1.0 indicates that an object would retain all of its velocity after bouncing. The value can be higher than 1 to increase the velocity after bouncing.

        Due to floating point precision and accuracy, a value of 1.0 may not produce a fully ellastic bounce (all the velocity is retained).

        Parameters:
        restitution - the coefficient of restitution; must be greater than zero
        Throws:
        IllegalArgumentException - if restitution is less than zero
      • getRestitutionVelocity

        public double getRestitutionVelocity()
        Returns the minimum velocity required to apply restitution.
        Returns:
        double
        Since:
        4.2.0
      • setRestitutionVelocity

        public void setRestitutionVelocity​(double restitutionVelocity)
        Sets the minimum velocity required to apply restitution.
        Parameters:
        restitutionVelocity - the velocity
        Since:
        4.2.0
      • createMass

        public Mass createMass()
        Creates a new Mass object using the set density and shape.
        Returns:
        Mass