Game Development Reference
// size to hand.
Vector3 normal = midline * (((real)1.0)/size);
Contact* contact = data->contacts;
contact->contactNormal = normal;
contact->contactPoint = positionOne + midline * (real)0.5;
contact->penetration = (one.radius+two.radius - size);
// Write the appropriate data.
contact->body = one.body;
contact->body = two.body;
contact->restitution = data->restitution;
contact->friction = data->friction;
C OLLIDING A S PHERE AND A P LANE
Colliding a sphere and a plane is just as simple as colliding two spheres. The sphere
collides with the plane if the distance of the center of the sphere is farther from the
plane than the sphere's radius. The distance of a point from a plane is given by
where l is the normal vector of the plane and l is the offset of the plane. This is a
standard way to represent a plane in 3D geometry.
We can represent the plane in code as
class Plane : public Primitive
Planes are almost always associated with immovable geometry rather than a rigid
body, so the rigid body pointer in the Primitive class will typically be NULL.
The algorithm takes a sphere and a plane and may add a contact to the contact
data. Again the algorithm is simple enough not to benefit from a separate early-out