ECE 2036 Project

Dependencies:   mbed wave_player 4DGL-uLCD-SE

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers physics.cpp Source File

physics.cpp

00001 #include "physics.h"
00002 #include "math_extra.h"
00003 
00004 void forward_euler(Physics* state, float delta)
00005 {
00006     // TODO: Implement proper forward euler updates for position and velocity
00007 
00008     // Compute random motion
00009 //    float damp = 0.5;
00010 //    float dx = damp*coin_flip();
00011 //    float dy = damp*coin_flip();
00012 
00013 //    state->px = state->px + dx;
00014 //    state->py = state->py + dy;
00015 //    state->vx = dx;
00016 //    state->vy = dy;
00017 
00018     // Update position and velocity
00019     state->vx += state->ax * delta;
00020     state->vy += state->ay * delta;
00021     state->px += state->vx * delta;
00022     state->py += state->vy * delta;
00023 
00024 }