Screen Shot 2016-03-08 at 8.42.19 am

BALL TRACKING ANIMATION

I needed some animations for the LED VEST. I decided to try making colours that move across the vest.

I like the fluidity and smooth feel of objects that have motion and inertia.

Using PROCESSING  I coded up a series of coloured blobs that move based on accelerating towards an object.

 

To achieve this I used vectors.

I set a position and a target, and applied an acceleration force to the object, which gave it a velocity. The velocity can then be used to move the object each frame of the animation.

private void accelerate()
{
 //First gets heading, second sets steering Force,
 //Easier to think about when done in two seperate objects " steeringHeading and steeringForce"

//target direction relative to me
 steeringDesired.set( (target.x - position.x), (target.y - positio n.y)); 
 steeringDesired.limit(maxVelocity);
 steeringCurrent = velocity.get();
 steeringForce = steeringDesired.get();
 steeringForce.sub(steeringCurrent);
 steeringForce.limit(acceleration);
 //now apply the force to the velocity
 velocity.x += steeringForce.x ;
 velocity.y += steeringForce.y ;
 //limit acceleration to max speed, otherwise the objects fly off  into deep space
 if(velocity.mag() > maxVelocity)//govern the speed
 {
  float overshoot = velocity.mag() / maxVelocity;
  velocity.x /= overshoot;
  velocity.y /= overshoot;
 }
}

 

This video shows the result of that application of force.

  • BLUE LINES = Velocity, longer is faster.
  • YELLOW LINES = Acceleration Force
  • RED DOT = Target Location
  • LONG GREY LINE = Direction to target