File: SVPolygon3d.mesa
Author: Eric Bier on August 21, 1982 1:40 pm
Last edited by Bier on February 18, 1987 6:18:07 pm PST
Contents: Most of the code necessary to describe the behavior of planes and polygons in space. (including the procedures necessary to make planar polygons act as master objects). Part of the Solidviews 3d Illustrator.
SVPolygon3d: CEDAR DEFINITIONS =
BEGIN
Matrix4by4: TYPE = SV3d.Matrix4by4;
Point3d: TYPE = SV3d.Point3d;
Polygon: TYPE = SV2d.Polygon;
Vector3d: TYPE = SV3d.Vector3d;
Poly3d: TYPE = REF Poly3dObj;
Poly3dObj: TYPE = SV3d.Poly3dObj;
Plane: TYPE = REF PlaneObj;
PlaneObj: TYPE = SV3d.PlaneObj;
CreatePoly: PROC [len: NAT] RETURNS [poly3d: Poly3d];
CircumHexagon:
PROC [y:
REAL, r:
REAL]
RETURNS [hex: Poly3d];
Creates a hexigon which circumscribes the circle (in the Y = y plane) whose center is at [0, y, 0] and whose radius is r.
ClearPoly: PROC [poly: Poly3d];
AddPolyPoint: PROC [poly: Poly3d, point: Point3d] RETURNS [polyPlusPoint: Poly3d];
PutPolyPoint: PROC [poly: Poly3d, index: NAT, point: Point3d] RETURNS [newPoly: Poly3d];
PartPolyGetsPartPoly:
PUBLIC
PROC [fromPoly: Poly3d, fromStart:
NAT, toPoly: Poly3d, toStart:
NAT, duration:
NAT]
RETURNS [newPoly: Poly3d];
toPoly in range [toStart..toStart+duration-1] gets fromPoly in range [fromStart..fromStart+duration-1];
PlaneFromPoly3d:
PROC [poly: Poly3d]
RETURNS [plane: Plane];
Assumes that the normal of the plane should point in the direction such that if the normal points toward a viewer, the viewer will perceive the points of poly to run clockwise.
PlaneFromPointAndNormal: PROC [point: Point3d, normal: Vector3d] RETURNS [plane: Plane];
PlaneFromCoefficients: PROC [A, B, C, D: REAL] RETURNS [plane: Plane];
SignedPointToPlaneDistance: PROC [point: Point3d, plane: Plane] RETURNS [distance: REAL];
ClipPolyToPlane: PROC [poly: Poly3d, plane: Plane] RETURNS [clippedPoly: Poly3d];
ClipPolyToPlanes: PROC [poly: Poly3d, planes: LIST OF Plane] RETURNS [clippedPoly: Poly3d];
LineSegmentMeetsPlane: PROC [p1, p2: Point3d, plane: Plane] RETURNS [intersection: Point3d];
ClipLineSegmentToPlane: PROC [p1, p2: Point3d, plane: Plane] RETURNS [newP1, newP2: Point3d, newP1isP1, newP2isP2, nullSegment: BOOL];
ClipLineSegmentToPlanes: PROC [p1, p2: Point3d, planes: LIST OF Plane] RETURNS [newP1, newP2: Point3d, newP1isP1, newP2isP2, nullSegment: BOOL];
NormalOfPlane: PROC [plane: Plane] RETURNS [normal: Vector3d];
PointOnNormalSideOfPlane: PROC [point: Point3d, plane: Plane] RETURNS [BOOL];
Quadrant: TYPE = {inin, inout, outin, outout};
QuadrantOfPoint:
PROC [point: Point3d, plane1, plane2: Plane]
RETURNS [Quadrant];
Classifies point with respect to two planes. outin means the point is on the normal side of the first plane and the non-normal side of the other plane, etc.
ProjectPolyToXYPlane: PROC [poly3d: Poly3d] RETURNS [polygon: Polygon];
ProjectPolyToYZPlane: PROC [poly3d: Poly3d] RETURNS [polygon: Polygon];
ProjectPolyToXZPlane: PROC [poly3d: Poly3d] RETURNS [polygon: Polygon];
TransformByMat:
PROC [poly3d: Poly3d, mat: Matrix4by4]
RETURNS [newPoly: Poly3d];
Perform the matrix transformation on every point of poly3d to get poly3d in a different coordinate frame.
END.