Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Collision in physics


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 Muzzy A   Members   -  Reputation: 687

Like
0Likes
Like

Posted 09 June 2012 - 01:43 AM

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
    if(IntersectRect(&colRect,&rect,&Other->rect))
    {
        // 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?



Sponsor:

#2 wildbunny   Members   -  Reputation: 550

Like
1Likes
Like

Posted 09 June 2012 - 05:37 PM

Have you read my article 'physics engines for dummies' where I cover the basics of a physics engine?

http://www.wildbunny.co.uk/blog/2011/04/06/physics-engines-for-dummies/

Cheers, Paul.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS