View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# Sphere Physics Simulation 3D (Impulse Based Reaction)

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.

3 replies to this topic

### #1Irlan Robson  Members

Posted 13 February 2013 - 12:14 PM

I'm trying to implement this method.. i'm not asking for you post your code but if you could help me you'll help the others too!
The angular velocity it's giving me numbers such like: 4.86313e-11 (something like that). I've checked out many many sources... Chris Hecker's website etc. and i didn't see the wrong side of this.

virtual void collide(Sphere& other)

{

Vector d;
float r;
float s;

d = (other.position - this->position); //collision normal (not normalized)
s = d.length() - r;

if (s < 0)

{

Vector cp, pt1, pt2, vel1, vel2, n, Vr;

cp = (other.position + this->position) / 2.0f; //collision point (sphere with same radius)

pt1 = cp - this->position; // collision point to center of mass vector
pt2 = cp - other.position;

//velocity at the point of contact
vel1 = this->velocity + this->ang_vel.cross(pt1);
vel2 = other.velocity + other.ang_vel.cross(pt2);

n = (other.position - this->position);
n.normalize();

Vr = (vel2 - vel1); //relative velocity

//collision data
collision.cn = n; // collision normal
collision.cp = cp; //collision point
collision.rv = Vr; //relative velocity

float f1 = -(1.0f + 0.804f) * Vr.dot(collision.cn);
float f2 = (1.0f / this->mass) + (1.0f / other.mass);
float f3 = ( (this->inverseInertia * pt1.cross(collision.cn).cross(pt1) ) +
(other.inverseInertia * pt2.cross(collision.cn).cross(pt2) ) ).dot(collision.cn);

float j = f1 / (f2 + f3);

velocity -= (j / mass) * collision.cn;
other.velocity += (j / other.mass) * collision.cn ;

ang_vel -= j * inverseInertia * pt1.cross(collision.cn);
other.ang_vel += j * other.inverseInertia * pt2.cross(collision.cn);

}

}

### #2EWClay  Members

Posted 13 February 2013 - 04:23 PM

Collisions between spheres without friction will not transfer any angular momentum, so I'd say that's as expected.

Your final cross products will be giving near zero because the vectors are parallel.

### #3Irlan Robson  Members

Posted 14 February 2013 - 08:17 AM

hm... can you give me the change in angular momentum equation for this???

### #4Irlan Robson  Members

Posted 14 February 2013 - 10:41 AM

hm i saw in another topic that angular momentum can be expressed by

dL = r x J (where J is the impulse vector) and r the position of the sphere...

thanks anyway... here is the topic if someone get interested

http://www.gamedev.net/topic/465248-calculating-impulse-due-to-rigid-body-collision-with-friction/

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.