Plane - Sphere Collision

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

Recommended Posts

I'm writing a simple plane-sphere (triangles and vertices etc. come later) collision test: obj is the sphere: its radius: obj->r its position: obj->x its speed: obj->v (There are also values for force, rotation etc) tri is a triangle with 3 corner vectors a,b,c (a being origin) and normal n. bool PoolPhysics::planeCollision(ball *obj, triangle *tri){ // The signed distance from the plane. Tri->n is assumed to be normalized double nx = tri->n.dotProduct(obj->x) - tri->n.dotProduct(tri->a); // Check if there already is some penetration. if(nx < THRESH + obj->r) return true; // The relative speed to the plane double nv = tri->n.dotProduct(obj->v /*+ obj->force* this->timeSinceLastFrame / obj->m*/); // If the ball has not already collided we check if its moving away or parallell to the plane. if(nv >= 0) return false; // The estimated time for collision (does not consider acceleration) double t0 = (obj->r - nx)/(nv); // The program uses the timesincelastframe to do its calculations // If the estimated collision time is smaller than the frame time // the collision will occur within one frame, we do an extra calculation at t0. if(t0 < this->timeSinceLastFrame) this->timeSinceLastFrame = t0; return false; } And it works quite well i suppose but its far from perfect. Anyone got any ideas on how to make this a bit better. Any help would be much appreciated =)

Share on other sites
What exactly is not working?

1. 1
2. 2
Rutin
19
3. 3
khawk
18
4. 4
5. 5
A4L
11

• 12
• 16
• 26
• 10
• 44
• Forum Statistics

• Total Topics
633767
• Total Posts
3013739
×