Physics-Simulator  v1.4.0-beta.2
cannonballs Namespace Reference

Functions

void addNew (LOC, LOC, double)
 
void clean_up (void)
 
void checkCollisons (uint)
 
bool checkOverlap (BOX, BOX)
 
void doCollide (uint, uint)
 

Variables

uint intCannonBallNum = 0
 
uint intRopeNum = 0
 
VectorCannon balls
 
VectorRope ropes
 

Function Documentation

◆ addNew()

void cannonballs::addNew ( LOC  mouseC,
LOC  mouseO,
double  HoldTime 
)

Will add a new cannonball based on the mouse start and mouse end. Mass of the ball will vary based on Hold Time

Parameters
mouseC= Current Mouse Location in X and Y
mouseO= Old (start of mouse click) Mouse Location in X and Y
HoldTime= Time (in seconds) that the mouse button was held down for
Returns
void
Here is the call graph for this function:

◆ checkCollisons()

void cannonballs::checkCollisons ( uint  j)

Checks ball number j is colliding with another ball and then do collisions.

Parameters
j= the number in the array that ball we are checking is.
Returns
void (all changes if they are colliding is handled in this function).
Here is the call graph for this function:

◆ checkOverlap()

bool cannonballs::checkOverlap ( BOX  A,
BOX  B 
)

Checks if two boxes overlap

Parameters
A= Box for ball A
B= Box for ball B
Returns
TRUE / FALSE if they overlap and therefore collide

◆ clean_up()

void cannonballs::clean_up ( void  )

Removes any "dead" balls/rope from the balls/rope vector and shrinks it to reduce memory usage

◆ doCollide()

void cannonballs::doCollide ( uint  numA,
uint  numB 
)

Will calculate the new velocities of two balls that are colliding

Equations.PNG
The equations used to get the resulting velocities.
Parameters
numA= the number in the array ball A is
numB= the number in the array ball B is
Returns
void (everything is handled inside the function)

Variable Documentation

◆ balls

VectorCannon cannonballs::balls

◆ intCannonBallNum

uint cannonballs::intCannonBallNum = 0

◆ intRopeNum

uint cannonballs::intRopeNum = 0

◆ ropes

VectorRope cannonballs::ropes