-
- All Implemented Interfaces:
DataContainer
public class BodyFixture extends Fixture implements DataContainer
Represents a piece of aPhysicsBody
.BodyFixture
extends theFixture
class, adding physical features like density and friction.- Since:
- 2.0.0
- Version:
- 4.0.0
- Author:
- William Bittle
- See Also:
Fixture
-
-
Field Summary
Fields Modifier and Type Field Description static double
DEFAULT_DENSITY
The default density in kg/m2; value =DEFAULT_DENSITY
static double
DEFAULT_FRICTION
The default coefficient of friction; value =DEFAULT_FRICTION
static double
DEFAULT_RESTITUTION
The default coefficient of restitution; value =DEFAULT_RESTITUTION
-
Constructor Summary
Constructors Constructor Description BodyFixture(Convex shape)
Minimal constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Mass
createMass()
Creates a newMass
object using the set density and shape.double
getDensity()
Returns the density of this shape in kg/m2.double
getFriction()
Returns the coefficient of friction.double
getRestitution()
Returns the coefficient of restitution.void
setDensity(double density)
Sets the density of this shape in kg/m2.void
setFriction(double friction)
Sets the coefficient of friction.void
setRestitution(double restitution)
Sets the coefficient of restitution.String
toString()
-
Methods inherited from class Fixture
getFilter, getShape, getUserData, isSensor, setFilter, setSensor, setUserData
-
Methods inherited from interface DataContainer
getUserData, setUserData
-
-
-
-
Field Detail
-
DEFAULT_FRICTION
public static final double DEFAULT_FRICTION
The default coefficient of friction; value =DEFAULT_FRICTION
- See Also:
- Constant Field Values
-
DEFAULT_RESTITUTION
public static final double DEFAULT_RESTITUTION
The default coefficient of restitution; value =DEFAULT_RESTITUTION
- See Also:
- Constant Field Values
-
DEFAULT_DENSITY
public static final double DEFAULT_DENSITY
The default density in kg/m2; value =DEFAULT_DENSITY
- See Also:
- Constant Field Values
-
-
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.
- Parameters:
density
- the density in kg/m2- Throws:
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.
- 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
-
-