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
664 Chapter 14 Distance Methods
14.9.1 Line to Oriented Box
A simple method for computing the distance between a line and an oriented box is to
iterate over the six faces of the box and compute the distance from the line to those
faces. If the line intersects a face, the distance is zero. The pseudocode is
float SquaredDistance (Line line, Box box, float& lClosest,
float bClosest[3])
{
float sqrDistance = infinity;
float tmpSD, tmpLC, tmpFC[2];
Rectangle face;
// Process the box face at -e0.
face.C = box.C - box.e[0] * box.axis[0];
face.axis[0] = box.axis[1];
face.axis[1] = box.axis[2];
face.e[0] = box.e[1];
face.e[1] = box.e[2];
tmpSD = SquaredDistance(line,face,tmpLC,tmpFC); ...
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