seltar.motion
Class Motion

java.lang.Object
  extended byseltar.motion.Motion

public class Motion
extends java.lang.Object


Field Summary
 float Const
           
 float Damp
           
 Point pos
           
 Point prevpos
           
 float Spring
           
 Vector v
           
 
Constructor Summary
Motion(float X, float Y)
          Constructor #1
Motion(float X, float Y, float VX, float VY)
          Constructor #2
 
Method Summary
 float calcAngle()
          Calculates angle from previous position to current position
 float calcAngle(float x1, float y1, float x2, float y2)
          Calculates the angle between two given points
 void constrain(float x1, float y1, float x2, float y2)
          Constrain Point pos and Point prevpos to given coordinates
 void followTo(float X, float Y)
          Sets Vector v Velocity & Direction Move point towards given point dividing by Const
 float getAngle()
          Gets angle from Vector v
 float getConstant()
          Gets Constant divider Used by followTo() & springTo()
 float getDamping()
          Gets Damping Used by springTo()
 float getDistance()
          Gets Distance from previous position to current position
 float getDistanceTo(float X, float Y)
          Gets Distance from current position to given position
 float getPX()
          Gets Previous X-position
 float getPY()
          Gets Previous Y-position
 float getSpring()
          Gets Springiness Used by springTo()
 float getVX()
          Gets current velocity-X
 float getVY()
          Gets current velocity-Y
 float getX()
          Gets current X-position
 float getY()
          Gets current Y-position
 void move()
          Sets prevpos to pos and Moves pos according to Vector v (Velocity & Direction)
 void moveDir(float Angle, float Speed)
          Sets Vector v Velocity & Direction Moves in a given Angle with a given Speed
 void setAngle(float A)
          Set angle in Vector v
 void setConstant(float C)
          Sets Constant divider Used by followTo() & springTo()
 void setDamping(float D)
          Sets Damping Used by springTo()
 void setPos(float X, float Y)
          Set current position to given coordinate
 void setPos(Point p)
          Set current position to given Point
 void setPrevPos(float X, float Y)
          Set previous position to given coordinate
 void setPrevPos(Point p)
          Set previous position to given Point
 void setPX(float PX)
          Set previous position to given float
 void setPY(float PY)
          Set previous position to given float
 void setSpring(float S)
          Sets Springiness Used by springTo()
 void setVelocity(float V)
          Set velocity in Vector v
 void setVelocity(float VX, float VY)
          Set velocity-coordinates in Vector v
 void setVX(float VX)
          Set X-velocity in Vector v
 void setVY(float VY)
          Set Y-velocity in Vector v
 void setX(float X)
          Set current X-position to given float
 void setY(float Y)
          Set current Y-position to given float
 void springTo(float X, float Y)
          Sets Vector v Velocity & Direction Springs point towards given point dividing by Const, multiplied with Spring and Damp
 void wrap(float x1, float y1, float x2, float y2)
          Wraps Point pos and Point prevpos around given coordinates
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

Damp

public float Damp

Const

public float Const

Spring

public float Spring

prevpos

public Point prevpos

pos

public Point pos

v

public Vector v
Constructor Detail

Motion

public Motion(float X,
              float Y)
Constructor #1

Parameters:
X - float X-position
Y - float Y-position

Motion

public Motion(float X,
              float Y,
              float VX,
              float VY)
Constructor #2

Parameters:
X - float X-position
Y - float Y-position
VX - float X-Velocity
VY - float Y-Velocity
Method Detail

getPX

public float getPX()
Gets Previous X-position

Returns:
float Previous X

getPY

public float getPY()
Gets Previous Y-position

Returns:
float Previous Y

getX

public float getX()
Gets current X-position

Returns:
float Current X

getY

public float getY()
Gets current Y-position

Returns:
float Current Y

getVX

public float getVX()
Gets current velocity-X

Returns:
float Velocity X

getVY

public float getVY()
Gets current velocity-Y

Returns:
float Velocity Y

calcAngle

public float calcAngle()
Calculates angle from previous position to current position

Returns:
float Angle

getAngle

public float getAngle()
Gets angle from Vector v

Returns:
float Angle

getConstant

public float getConstant()
Gets Constant divider Used by followTo() & springTo()

Returns:
float Constant

getDamping

public float getDamping()
Gets Damping Used by springTo()

Returns:
float Damping

getSpring

public float getSpring()
Gets Springiness Used by springTo()

Returns:
float Springiness

getDistance

public float getDistance()
Gets Distance from previous position to current position

Returns:
float Distance

getDistanceTo

public float getDistanceTo(float X,
                           float Y)
Gets Distance from current position to given position

Returns:
float Distance

setPos

public void setPos(Point p)
Set current position to given Point

Parameters:
p - Position

setPos

public void setPos(float X,
                   float Y)
Set current position to given coordinate

Parameters:
X - X-position
Y - Y-position

setX

public void setX(float X)
Set current X-position to given float

Parameters:
X - X-position

setY

public void setY(float Y)
Set current Y-position to given float

Parameters:
Y - Y-position

setPrevPos

public void setPrevPos(Point p)
Set previous position to given Point

Parameters:
p - Previous Position

setPrevPos

public void setPrevPos(float X,
                       float Y)
Set previous position to given coordinate

Parameters:
X - Previous X-Position
Y - Previous Y-Position

setPX

public void setPX(float PX)
Set previous position to given float

Parameters:
PX - Previous X-Position

setPY

public void setPY(float PY)
Set previous position to given float

Parameters:
PY - Previous Y-Position

setAngle

public void setAngle(float A)
Set angle in Vector v

Parameters:
A - Angle

setVelocity

public void setVelocity(float V)
Set velocity in Vector v

Parameters:
V - Velocity

setVelocity

public void setVelocity(float VX,
                        float VY)
Set velocity-coordinates in Vector v

Parameters:
VX - X-Velocity
VY - Y-Velocity

setVX

public void setVX(float VX)
Set X-velocity in Vector v

Parameters:
VX - X-Velocity

setVY

public void setVY(float VY)
Set Y-velocity in Vector v

Parameters:
VY - Y-Velocity

setConstant

public void setConstant(float C)
Sets Constant divider Used by followTo() & springTo()

Parameters:
C - Constant

setDamping

public void setDamping(float D)
Sets Damping Used by springTo()

Parameters:
D - Damping

setSpring

public void setSpring(float S)
Sets Springiness Used by springTo()

Parameters:
S - Springiness

wrap

public void wrap(float x1,
                 float y1,
                 float x2,
                 float y2)
Wraps Point pos and Point prevpos around given coordinates


constrain

public void constrain(float x1,
                      float y1,
                      float x2,
                      float y2)
Constrain Point pos and Point prevpos to given coordinates


calcAngle

public float calcAngle(float x1,
                       float y1,
                       float x2,
                       float y2)
Calculates the angle between two given points

Returns:
float Angle

move

public void move()
Sets prevpos to pos and Moves pos according to Vector v (Velocity & Direction)


moveDir

public void moveDir(float Angle,
                    float Speed)
Sets Vector v Velocity & Direction Moves in a given Angle with a given Speed


followTo

public void followTo(float X,
                     float Y)
Sets Vector v Velocity & Direction Move point towards given point dividing by Const


springTo

public void springTo(float X,
                     float Y)
Sets Vector v Velocity & Direction Springs point towards given point dividing by Const, multiplied with Spring and Damp