Module org.dyn4j

Class BodyFixture

    • Field Detail

      • 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
    • Constructor Detail

      • BodyFixture

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

      • toString

        public java.lang.String toString()
        Overrides:
        toString in class Fixture
      • 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.

        Parameters:
        density - the density in kg/m2
        Throws:
        java.lang.IllegalArgumentException - if density is less than or equal to 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.

        Since two BodyFixtures participate in a collision, their coefficients will be mixed by a CoefficientMixer to product a single value for the collision.

        Parameters:
        friction - the coefficient of friction; must be greater than zero
        Throws:
        java.lang.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).

        Since two BodyFixtures participate in a collision, their coefficients will be mixed by a CoefficientMixer to product a single value for the collision.

        Parameters:
        restitution - the coefficient of restitution; must be greater than zero
        Throws:
        java.lang.IllegalArgumentException - if restitution is less than zero
      • createMass

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