com.blogspot.applications4android.comicreader.zoom
Class FrictionSpringDynamix

java.lang.Object
  extended by com.blogspot.applications4android.comicreader.zoom.FrictionSpringDynamix

public class FrictionSpringDynamix
extends java.lang.Object

Uses friction and spring physics in order to provide a more realistic UI. Logic is that when inside the bounds, we'll use friction factor. But as soon as we go out of bounds, we'll apply spring physics.


Constructor Summary
FrictionSpringDynamix()
           
 
Method Summary
 float getPosition()
          Get current position
 float getVelocity()
          Get current velocity
 boolean isUnderRest(float vel_tol, float pos_tol)
          Finds out whether the object is at rest and is inside the bounds.
 void setMinMax(float min, float max)
          Set bounds for this object.
 void setParameters(float fric, float stiff, float damp)
          Set the parameters for this object
 void setState(float vel, float pos)
          Set the current state of this object.
 void setState(float vel, float pos, long time)
          Set the current state of this object.
 void update()
          Interface function responsible for evaluation of the current velocity and position.
 void update(long time)
          Interface function responsible for evaluation of the current velocity and position.
protected  void updateState(long delta)
          The base function responsible for actual evaluation of velocity and position for the current time step.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FrictionSpringDynamix

public FrictionSpringDynamix()
Method Detail

setState

public void setState(float vel,
                     float pos,
                     long time)
Set the current state of this object.

Parameters:
vel - current velocity
pos - current position
time - current time

setState

public void setState(float vel,
                     float pos)
Set the current state of this object. (time is assumed to be 'now')

Parameters:
vel - current velocity
pos - current position

setMinMax

public void setMinMax(float min,
                      float max)
Set bounds for this object.

Parameters:
min - the minimum possible value for position.
max - the maximum possible value for position.

getVelocity

public float getVelocity()
Get current velocity

Returns:
current velocity

getPosition

public float getPosition()
Get current position

Returns:
current position

isUnderRest

public boolean isUnderRest(float vel_tol,
                           float pos_tol)
Finds out whether the object is at rest and is inside the bounds.

Parameters:
vel_tol - velocity tolerance. If current velocity is less than this tolerance, then it is considered to be at rest.
pos_tol - position tolerance. tolerance to be added to the bounds to check for limits.

update

public void update(long time)
Interface function responsible for evaluation of the current velocity and position.

Parameters:
time - current time.

update

public void update()
Interface function responsible for evaluation of the current velocity and position. Assumes the time to be 'now'.


setParameters

public void setParameters(float fric,
                          float stiff,
                          float damp)
Set the parameters for this object

Parameters:
fric - friction co-efficient
stiff - stiffness of the string
damping - ratio

updateState

protected void updateState(long delta)
The base function responsible for actual evaluation of velocity and position for the current time step.

Parameters:
delta - the delta time elapsed from the last update.