• Advertisement
Sign in to follow this  

reaction off non moveable object

This topic is 4594 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 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 this post


Link to post
Share on other sites
Advertisement
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement