• Advertisement
Sign in to follow this  

Collision in physics

This topic is 2083 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Sign in to follow this  

  • Advertisement