Language:EN
Pages: 2
Rating : ⭐⭐⭐⭐⭐
Price: $10.99
Page 1 Preview
unsigned collisiondetector sphere sphere

Unsigned collisiondetector sphere sphere

284 Chapter 13 Generating Contacts

Excerpt from src/collide_fine.cpp

Separating axes between a box and a sphere.

The fnal phase of our algorithm is to fnd the closest point i
point and generate the contact from it. We’ll do this frst in the
This is a simple process. All we need to do is to clamp each
point to the half-size of the box in the same direction. With
then work out the distance from the center of the sphere to th
if it is larger than the radius of the sphere. The code for this is simple:

Excerpt from src/collide_fine.cpp

13.3 Primitive Collision Algorithms

dist = relCenter.x;
if (dist > box.halfSize.x) dist = box.halfSize.x; if (dist < -box.halfSize.x) dist = -box.halfSize.x; closestPt.x = dist;

dist = relCenter.y;
if (dist > box.halfSize.y) dist = box.halfSize.y; if (dist < -box.halfSize.y) dist = -box.halfSize.y; closestPt.y = dist;

Excerpt from src/collide_fine.cpp

// Compile the contact.

)

{

const Sphere &sphere,
CollisionData *data

You are viewing 1/3rd of the document.Purchase the document to get full access instantly

Immediately available after payment
Both online and downloadable
No strings attached
How It Works
Login account
Login Your Account
Place in cart
Add to Cart
send in the money
Make payment
Document download
Download File
img

Uploaded by : Indrajit Sundaram

PageId: ELI0343F4A