Sign in to follow this  
Muzzy A

Collision in physics

Recommended Posts

I began testing the physics I learned in school about 7 months ago or so. Once I started I realized that... I forgot it all lol. To test my physics i basically made 3 rectangles move in random directions and acceleration is CONSTANTLY increasing on each of them.

the collision is basically what I'm working on.

ive looked all over google but i can't find anything that really helps me, or at least i don't understand most of it.

in my object class i have
Rect rect; // The rectangle I am drawing and checking collision with
Vector2 pos;
Vector2 velocity;
Vector2 acceleration;
Vector2 momentum; // I can't remember if this is supposed to be a vector or a number lol
float mass;

// I know how to calculate the momentum
momentum = mass * velocity;

void CheckCollision(Object *Other)
float dt = time.GetDeltaTime();

RECT colRect;

// Check for a collision
// There was a collision, now lets do physics

// Calculate the force first? And im not sure if I'm doing this correctly, cause you can't multiply a vector by another vector
Vector2 myForce = mass * momentum * velocity;
Vector2 otherForce = Other->mass * Other->momentum * Other->velocity;

// I'm not sure if i know how to calculate the impulse either, this is from what I remember + what I gathered online that i couldn't really understand
Vector2 impulse = myForce-otherForce * dt;

// I just want to do the collision with physics without anything else involved like: Friction,Gravity, Air Resistance or what have you.

// Do I need to use the Coefficient of Restitution? and if so what exactly is that and how do I calculate it?


Share this post

Link to post
Share on other sites
Have you read my article 'physics engines for dummies' where I cover the basics of a physics engine?

Cheers, Paul.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this