-- File: SVPolygon3d.mesa -- Last edited by Bier on December 18, 1982 1:07 am -- Author: Eric Bier on August 21, 1982 1:40 pm -- 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. DIRECTORY Matrix3d, SVPolygon2d, SVVector3d; SVPolygon3d: DEFINITIONS = BEGIN Point3d: TYPE = Matrix3d.Point3d; Polygon: TYPE = SVPolygon2d.Polygon; Vector: TYPE = SVVector3d.Vector; Poly3d: TYPE = REF Poly3dObj; Poly3dObj: TYPE = RECORD [ len: NAT, seq: SEQUENCE maxVerts: NAT OF Point3d]; Plane: TYPE = REF PlaneObj; PlaneObj: TYPE = RECORD [ A, B, C, D: REAL]; -- plane equation: ax + by + cz + d = 0; -- the normal vector is [a, b, c]; -- The y = 0 plane for instance has A = C = D = 0; -- If b = 1 THEN normal is [0, 1, 0] pointing up. Plug in point (4, 5, 6) = 5 (pos, normal side, up). -- If b = -1 THEN normal is [0, -1, 0] pointing down. Plug in point (4, 5, 6) = -5 (neg, not normal side, up). 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 if the normal points toward a viewer, the viewer will perceive the points of poly to run clockwise. PlaneFromPointAndNormal: PROC [point: Point3d, normal: Vector] RETURNS [plane: Plane]; SignedPointToPlaneDistance: PROC [point: Point3d, plane: Plane] RETURNS [distance: REAL]; NormalOfPlane: PROC [plane: Plane] RETURNS [normal: Vector]; PointOnNormalSideOfPlane: PROC [point: Point3d, plane: Plane] RETURNS [BOOL]; Quadrant: TYPE = {inin, inout, outin, outout}; QuadrantOfPoint: PROC [point: Point3d, plane1, plane2: Plane] RETURNS [Quadrant]; -- classifys 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]; END. ส–– "Mesa" style˜Iprocšฎฯcœ4œฯk œ5ž œžœ žœžœ žœžœžœžœžœ žœžœ žœžœžœžœžœžœžœžœžœžœžœ)œ#œ3œgœoœฯn œžœžœžœŸ œžœžœžœžœ}Ÿ œžœŸ œžœAŸ œžœžœ,Ÿœž œžœžœ žœ6œ.œŸœžœžœฏœŸœžœ"žœŸœžœ žœ žœŸ œžœžœŸœžœ žœžœ žœ!Ÿœžœ)žœ œŸœžœžœŸœžœžœŸœžœžœžœ˜˜—…—  ถ