G3dPlane.mesa
Copyright Ó 1984, 1992 by Xerox Corporation. All rights reserved.
Bloomenthal, July 14, 1992 1:49 pm PDT
Andrew Glassner February 19, 1991 4:06 pm PST
Ken Fishkin, November 6, 1991 1:06 pm PST
DIRECTORY G3dBasic, G3dMatrix, Rope;
G3dPlane: CEDAR DEFINITIONS
~ BEGIN
Errors
Error: ERROR [reason: ROPE];
Type Declarations
Plane:    TYPE ~ RECORD [x, y, z, w: REAL ¬ 0.0, normalized: BOOL ¬ FALSE];
MajorPlane:  TYPE ~ {xy, xz, yz, unknown};    -- the xy, xz, or yz planes
PlaneSequence:    TYPE ~ REF PlaneSequenceRep;
PlaneSequenceRep:   TYPE ~ RECORD [
length:       CARDINAL ¬ 0,
element:       SEQUENCE maxLength: NATURAL OF Plane
];
Circle:   TYPE ~ G3dBasic.Circle;
NatSequence:  TYPE ~ G3dBasic.NatSequence;
Pair:    TYPE ~ G3dBasic.Pair;
PairSequence: TYPE ~ G3dBasic.PairSequence;
Ray:    TYPE ~ G3dBasic.Ray;
Sign:    TYPE ~ G3dBasic.Sign;
Triple:   TYPE ~ G3dBasic.Triple;
TripleSequence: TYPE ~ G3dBasic.TripleSequence;
Matrix:   TYPE ~ G3dMatrix.Matrix;
ROPE:    TYPE ~ Rope.ROPE;
Plane Creations
FromPolygon: PROC [points: TripleSequence, polygon: NatSequence ¬ NIL] RETURNS [Plane];
Return unitized plane passing as close as possible to all points.
If polygon # NIL, use as points index.
Can raise Error[$NullVec, "points colinear"].
FromThreePoints: PROC [p1, p2, p3: Triple, unitize: BOOL ¬ FALSE] RETURNS [Plane];
Return plane passing through three points, with normal pointing away if the three
points appear in clockwise order; unitize the plane iff unitize is TRUE.
Can raise Error[$NullVec, "null plane normal"].
FromThreePointsAndBehind: PROC [p1, p2, p3, behind: Triple, unitize: BOOL ¬ FALSE]
RETURNS [Plane];
Return plane passing through three points, with the normal oriented such that
point (behind) is considered behind the plane.
FromPointAndNormal: PROC [point, normal: Triple, unitize: BOOL ¬ FALSE]
RETURNS [Plane];
Return plane given point on plane and normal to plane;
unitize the plane iff unitize is TRUE. Can raise Error[$NullVec, "null plane normal"].
DFromNormalAndPoints: PROC [
normal: Triple,
points: TripleSequence,
polygon: NatSequence ¬ NIL]
RETURNS [REAL];
Return distance from plane to origin.
NormalFromPlane: PROC [plane: Plane, unit: BOOL ¬ FALSE] RETURNS [Triple];
Return the normal to the plane.
Plane Modifications
Unit: PROC [plane: Plane] RETURNS [Plane];
Return unitized plane (i.e., plane normal is of unit length).
Can raise Error[$NullVec, "null plane normal"].
Intersections
IntersectionOf3: PROC [p1, p2, p3: Plane] RETURNS [Triple];
Return point of intersection of planes.
Can raise Error[$ZeroDiv, "no intersection"].
IntersectionOf2: PROC [plane1, plane2: Plane] RETURNS [Ray];
Return base and axis of line intersection of planes.
Can raise Error[$NullVec, "no intersection"].
IntersectWithLine: PROC [plane: Plane, line: Ray] RETURNS [Triple];
Return intersection point of plane and line.
Can raise Error[$ZeroDiv, "no intersection"].
Projections
ProjectPointToPlane: PROC [point: Triple, plane: Plane] RETURNS [Triple];
Project point onto the plane, assuming the plane normal is of unit length.
ProjectVectorToPlane: PROC [v: Triple, plane: Plane] RETURNS [Triple];
Project the vector onto the plane.
ProjectPointToMajorPlane: PROC [p: Triple, majorPlane: MajorPlane] RETURNS [Pair];
Return p projected to the specified major plane.
ProjectPointsToXYPlane: PROC [points: TripleSequence] RETURNS [PairSequence];
Project points onto the xy plane.
ProjectPointsToXZPlane: PROC [points: TripleSequence] RETURNS [PairSequence];
Project points onto the xz plane.
ProjectPointsToYZPlane: PROC [points: TripleSequence] RETURNS [PairSequence];
Project points onto the yz plane.
ProjectPointsToMajorPlane: PROC [points: TripleSequence, majorPlane: MajorPlane]
RETURNS [PairSequence];
Project points onto a major plane.
Miscellany
Side: PROC [point: Triple, plane: Plane] RETURNS [Sign];
Return the which side of the plane point is on.
Negate: PROC [plane: Plane] RETURNS [Plane];
Reverse the plane equation so the positive and negative half-spaces are swapped.
AlignWithXYPlane: PROC [plane: Plane, out: Matrix ¬ NIL] RETURNS [Matrix];
Return the matrix that transforms points on plane to points on the xy plane. That is, the
plane's center is transformed to the origin and the plane's normal is transformed to the z-axis.
Use out if non-NIL.
ClosestPair: PROC [pairs: PairSequence, pair: Pair] RETURNS [NAT];
Return the index into pairs of that element of the sequence closest to pair.
GetMajorPlane: PROC [plane: Plane] RETURNS [MajorPlane];
Return the major plane most aligned with plane.
CenterOfPlane: PROC [plane: Plane] RETURNS [Triple];
Return intersection of plane and line from origin normal to plane.
DistanceToPoint: PROC [point: Triple, plane: Plane, unitize: BOOL ¬ TRUE]
RETURNS [REAL];
Return the distance from a point to a plane.
Distance is positive if point is in front, negative if behind, plane.
Can raise Error[$NullVec, "null plane normal"].
If unitize, first unitize the plane equation.
CircleFromPoints: PROC [p1, p2, p3: Triple] RETURNS [Circle];
Find center and radius of circle passing through given three points.
Can raise Error[$NullVec, "points collinear"].
Plane Sequences
CopyPlaneSequence: PROC [planes: PlaneSequence] RETURNS [PlaneSequence];
AddToPlaneSequence: PROC [planes: PlaneSequence, plane: Plane] RETURNS [PlaneSequence];
LengthenPlaneSequence: PROC [planes: PlaneSequence, amount: REAL ¬ 1.3] RETURNS [PlaneSequence];
END.