public class ForceSimulator
extends java.lang.Object
Force
functions and choose an
appropriate Integrator
.Constructor and Description |
---|
ForceSimulator()
Create a new, empty ForceSimulator.
|
ForceSimulator(Integrator integr)
Create a new, empty ForceSimulator.
|
Modifier and Type | Method and Description |
---|---|
void |
accumulate()
Accumulate all forces acting on the items in this simulation
|
void |
addForce(Force f)
Add a new Force function to the simulator.
|
void |
addItem(ForceItem item)
Add a ForceItem to the simulation.
|
Spring |
addSpring(ForceItem item1,
ForceItem item2)
Add a Spring to the simulation.
|
Spring |
addSpring(ForceItem item1,
ForceItem item2,
float length)
Add a Spring to the simulation.
|
Spring |
addSpring(ForceItem item1,
ForceItem item2,
float coeff,
float length)
Add a Spring to the simulation.
|
void |
clear()
Clear this simulator, removing all ForceItem and Spring instances
for the simulator.
|
Force[] |
getForces()
Get an array of all the Force functions used in this simulator.
|
Integrator |
getIntegrator()
Get the Integrator used by this simulator.
|
java.util.Iterator |
getItems()
Get an iterator over all registered ForceItems.
|
float |
getSpeedLimit()
Get the speed limit, or maximum velocity value allowed by this
simulator.
|
java.util.Iterator |
getSprings()
Get an iterator over all registered Springs.
|
boolean |
removeItem(ForceItem item)
Remove a ForceItem to the simulation.
|
void |
runSimulator(long timestep)
Run the simulator for one timestep.
|
void |
setIntegrator(Integrator intgr)
Set the Integrator used by this simulator.
|
void |
setSpeedLimit(float limit)
Set the speed limit, or maximum velocity value allowed by this
simulator.
|
public ForceSimulator()
public ForceSimulator(Integrator integr)
integr
- the Integrator to usepublic float getSpeedLimit()
public void setSpeedLimit(float limit)
limit
- the "speed limit" maximum velocity value to usepublic Integrator getIntegrator()
public void setIntegrator(Integrator intgr)
intgr
- the Integrator to usepublic void clear()
public void addForce(Force f)
f
- the Force function to addpublic Force[] getForces()
public void addItem(ForceItem item)
item
- the ForceItem to addpublic boolean removeItem(ForceItem item)
item
- the ForceItem to removepublic java.util.Iterator getItems()
public Spring addSpring(ForceItem item1, ForceItem item2)
item1
- the first endpoint of the springitem2
- the second endpoint of the springpublic Spring addSpring(ForceItem item1, ForceItem item2, float length)
item1
- the first endpoint of the springitem2
- the second endpoint of the springlength
- the spring lengthpublic Spring addSpring(ForceItem item1, ForceItem item2, float coeff, float length)
item1
- the first endpoint of the springitem2
- the second endpoint of the springcoeff
- the spring coefficientlength
- the spring lengthpublic java.util.Iterator getSprings()
public void runSimulator(long timestep)
timestep
- the span of the timestep for which to run the simulatorpublic void accumulate()
Copyright ? 2013 Regents of the University of California