volatileprototypes.fvlib
Class BehaviorConstantDistance

java.lang.Object
  extended by volatileprototypes.fvlib.Solver
      extended by volatileprototypes.fvlib.Behavior
          extended by volatileprototypes.fvlib.BehaviorConstantDistance

public final class BehaviorConstantDistance
extends Behavior

Since:
0.4.0

Nested Class Summary
 
Nested classes/interfaces inherited from class volatileprototypes.fvlib.Solver
Solver.Caller
 
Field Summary
 
Fields inherited from class volatileprototypes.fvlib.Behavior
points
 
Fields inherited from class volatileprototypes.fvlib.Solver
xs
 
Constructor Summary
BehaviorConstantDistance()
          Constructor, generates a new class instance.
BehaviorConstantDistance(java.util.ArrayList<? extends Point> pointsin)
          Constructor, generates a new class instance using a copy of the supplied Point ArrayList.
BehaviorConstantDistance(Point[] pointsin)
          Constructor, generates a new class instance using the supplied Point array.
 
Method Summary
 float getC()
          Returns the rest length of the virtual springs.
protected  int getNumCPUs()
           
 float getRange()
          Returns the range value.
 float getS()
          Returns the stiffness of the virtual springs.
 BehaviorConstantDistance setC(float cin)
          Sets the rest length, the length at which points exert no force between each other.
 BehaviorConstantDistance setFast(boolean fin)
          Sets whether to use a faster solver or the normal one.
 BehaviorConstantDistance setRange(float rin)
          Sets the maximum range below which objects will interact.
 BehaviorConstantDistance setS(float sin)
          Sets the stiffness of the virtual spring used to keep object distance.
protected  void stepFunction(int step, int offset)
           
 
Methods inherited from class volatileprototypes.fvlib.Behavior
getP, setP, setP
 
Methods inherited from class volatileprototypes.fvlib.Solver
finalizeFunction, step
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BehaviorConstantDistance

public BehaviorConstantDistance()
Constructor, generates a new class instance.


BehaviorConstantDistance

public BehaviorConstantDistance(java.util.ArrayList<? extends Point> pointsin)
Constructor, generates a new class instance using a copy of the supplied Point ArrayList.

Parameters:
pointsin - An ArrayList containing Point objects with which the object's list will be initialized.

BehaviorConstantDistance

public BehaviorConstantDistance(Point[] pointsin)
Constructor, generates a new class instance using the supplied Point array.

Parameters:
pointsin - An array containing Point objects with which the object's array will be initialized.
Method Detail

getNumCPUs

protected int getNumCPUs()
Overrides:
getNumCPUs in class Solver

setC

public BehaviorConstantDistance setC(float cin)
Sets the rest length, the length at which points exert no force between each other.

Parameters:
cin - A float representing the new rest distance value.
Returns:
The current object.

setS

public BehaviorConstantDistance setS(float sin)
Sets the stiffness of the virtual spring used to keep object distance. The stiffness of the virtual springs used to keep the object distance in this behavior is an float value between 0.0 and 0.5, with 0.5 being the stiffest. Be aware that high values may easily cause instability of the physics system.

Parameters:
sin - A float representing the new stiffness value.
Returns:
The current object.

setRange

public BehaviorConstantDistance setRange(float rin)
Sets the maximum range below which objects will interact.

Parameters:
rin - A float representing the new range.
Returns:
The current object.

getC

public float getC()
Returns the rest length of the virtual springs.

Returns:
The rest length value.

getS

public float getS()
Returns the stiffness of the virtual springs.

Returns:
The stiffness value.

getRange

public float getRange()
Returns the range value.

Returns:
The range value.

setFast

public final BehaviorConstantDistance setFast(boolean fin)
Sets whether to use a faster solver or the normal one. In fvlib, a fast solver is implemented for spring interactions that uses just one Newton iteration to approximate the square root of the squared length between points using the rest length as reference. The faster solver reduces precision but increases simulation speed noticeably.

Parameters:
fin - A boolean representing whether to use fast sqrt.
Returns:
The current object.

stepFunction

protected final void stepFunction(int step,
                                  int offset)
Overrides:
stepFunction in class Solver