Skip to Main Content
3D Game Engine Design, 2nd Edition
book

3D Game Engine Design, 2nd Edition

by David Eberly
November 2006
Intermediate to advanced content levelIntermediate to advanced
1040 pages
26h 31m
English
CRC Press
Content preview from 3D Game Engine Design, 2nd Edition
14.11 Rectangle to Oriented Box 669
14.11 Rectangle to Oriented Box
The algorithm for computing the squared distance between a rectangle and an ori-
ented box may be chosen similarly to that for a triangle and an oriented box. The
pseudocode is
float SquaredDistance (Rectangle rectangle, Box box,
float rClosest[2], float bClosest[3])
{
for (i1 = 0; i1 < 2; i1++)
{
float param1 = (2 * i1 - 1) * rectangle.e[1];
Vector3 delta1 = param1 * rectangle.axis[1];
for (i0 = 0; i0 < 2; i0++)
{
float param0 = (2 * i0 - 1) * rectangle.e[0];
Vector3 delta0 = param0 * rectangle.axis[0];
Vector3 corner = rectangle.C + delta0 + delta1;
if (PointInBox(corner))
{
tClosest[0] = param0;
tClosest[1] = param1;
Vector3f diff = corner - box.C;
for(j=0;j<3;j++)
{
bClosest[j] = Dot(box.axis[j],diff); ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

3D Game Engine Architecture

3D Game Engine Architecture

David Eberly
Blender 3D By Example - Second Edition

Blender 3D By Example - Second Edition

Oscar Baechler, Xury Greer
Computer Graphics

Computer Graphics

Alexey Boreskov, Evgeniy Shikin

Publisher Resources

ISBN: 9781482267303