G3dBox.mesa
Copyright Ó 1985, 1992 by Xerox Corporation. All rights reserved.
Glassner, February 14, 1991 10:13 am PST
Jules Bloomenthal July 14, 1992 1:51 pm PDT
Ken Fishkin, August 25, 1992 1:16 pm PDT
DIRECTORY G3dBasic, G3dShape;
G3dBox: CEDAR DEFINITIONS
~ BEGIN
Imported Types
Box:     TYPE ~ G3dBasic.Box;
NatSequence:   TYPE ~ G3dBasic.NatSequence;
Surface:    TYPE ~ G3dBasic.Surface;
Triple:    TYPE ~ G3dBasic.Triple;
TripleSequence:  TYPE ~ G3dBasic.TripleSequence;
VertexSequence:  TYPE ~ G3dShape.VertexSequence;
Creation
BoxFromPoints: PROC [p0, p1: Triple] RETURNS [Box];
Return a box which contains the two points.
BoxFromSurface: PROC [surf: Surface, verts: VertexSequence] RETURNS [Box];
Return the box which contains the surface.
BoxFromVertices: PROC [nats: NatSequence, verts: VertexSequence] RETURNS [Box];
Return the smallest box which contains the vertices indicated in the sequence.
BoxFromTripleSequence: PROC [ts: TripleSequence] RETURNS [Box];
Return the smallest box which contains all points in the TripleSequence.
Tests
Intersect: PROC [box1, box2: Box] RETURNS [has: BOOL, intersection: Box];
If the two boxes intersect, (has) is TRUE, and (intersection) is their intersection. If they do not intersect, (has) is FALSE, and (intersection) is undefined.
PointInBox: PROC [box: Box, pt: Triple] RETURNS [BOOL];
Return TRUE iff the given point is inside the given box.
Combination
BoxUnionBox: PROC [b1, b2: Box] RETURNS [Box];
Return the smallest box which contains both input boxes
BoxUnionPoint: PROC [box: Box, point: Triple] RETURNS [Box];
Return the smallest box which contiains the input box and the point
Modification
BoxMap: PROC [rel, abs: Box] RETURNS [Box];
Return the box defined by considering 'rel' as relative coordinates in 'abs'.
Derived Data
BoxCenter: PROC [box: Box] RETURNS [Triple];
Return the center of the box.
BoxEdges: PROC [box: Box] RETURNS [Triple];
Return the magnitudes of the lengths of the three edges.
Utility Procs
Lerp: PROC [alpha, low, high: REAL] RETURNS [REAL];
Linear interpolation. When alpha=0, return low, when alpha=1, return high.
Min3d: PROC [p0, p1: Triple] RETURNS [Triple];
Return the component-wise minimum of two points.
Max3d: PROC [p0, p1: Triple] RETURNS [Triple];
Return the component-wise maximum of two points.
END.