reaction off non moveable object

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

Recommended Posts

I have the collision and a reaction working, I dont yet have the reaction I want... i am just apply the inverse force of the object thus sending him back from where he came... all i want is to find the correct perp angle to send it.. is there a way to do that if you only know 2 points p1(the point that made contact with imoobile object) p2( the previous point that had no contact)..... currnetly i am finding the collision normal by taking (p2 - p1) ... I am not looking for a perfect reaction just one that would send the obeject in the correct 45degree perp.. heres what i got
void CEntity::handleStaticCollision(CVector2D & collisionNormal)
{
float impulse;
CVector2D VRelativeVelocity;

collisionNormal.normalize();

VRelativeVelocity = this->m_VLinearVelocity;
VRelativeVelocity *= -(1 + this->m_coeffOfRestitution);

float inverseMassSum;
inverseMassSum =  (1 / this->m_mass) + (1 / 10000000 // - MASS- because its a non moveable object);

float tester = collisionNormal.dotProduct(collisionNormal * inverseMassSum);

impulse = (VRelativeVelocity.dotProduct(collisionNormal)) / collisionNormal.dotProduct(collisionNormal * inverseMassSum);

this->m_VLinearVelocity = this->m_VLinearVelocity + collisionNormal * (impulse / this->m_mass);

}


any ways.. if anyone can shine some light please do...... h

Share on other sites
This formula computes the new direction, given the original direction (D) and the normal to the surface (N). Both must be normalized.

Dreflected = D - 2 * dot( N, D ) * N

1. 1
2. 2
3. 3
frob
14
4. 4
5. 5
Rutin
12

• 12
• 9
• 57
• 14
• 15
• Forum Statistics

• Total Topics
632112
• Total Posts
3004176

×