File: SV2d.mesa
Author: Eric Bier on August 20, 1982 11:39 am
Last edited by Bier on July 29, 1984 2:22:26 pm PDT
Contents: Definitions of data structures used to represent two dimensional entities, and procedures to support them. Part of the Solidviews Three Dimensional Illustrator.
SV2d: DEFINITIONS =
BEGIN
Point2d: TYPE = ARRAY[1..2] OF REAL;
Vector2d: TYPE = ARRAY[1..2] OF REAL;
Matrix3by3: TYPE = ARRAY [1..3] OF ARRAY [1..3] OF REAL;
Polygons and Paths
Polygon: TYPE = REF PolygonObj;
PolygonObj: TYPE = RECORD [
len: NAT, seq: SEQUENCE maxVerts: NAT OF Point2d];
Path: TYPE = REF PathObj;
PathObj: TYPE = RECORD [
len: NAT, seq: SEQUENCE maxVerts: NAT OF Point2d];
TrigPolygon: TYPE = REF TrigPolygonObj;
TrigPolygonObj: TYPE = RECORD [
len: NAT, seq: SEQUENCE maxVerts: NAT OF TrigLineSeg];
A possible substitute for TrigLineSeg
LineSeg: TYPE = REF LineSegObj;
LineSegObj: TYPE = RECORD [
p1, p2: Point2d,
slope: REAL,
xInt, yInt: REAL,
isVert: BOOL
];
TrigLineSeg: TYPE = REF TrigLineSegObj;
A TrigLine with endpoints pLo and pHi.
pLo has lower y than pHi or the same y and lower x.
TrigLineSegObj: TYPE = RECORD [
line: TrigLine,
pLo, pHi: Point2d,
pLoIsFirst: BOOL]; -- Are [pLo, pHi] in the same order as [v1, v2] (the segment endpoints as they are given to CreateTrigLineSeg)?
TrigLine: TYPE = REF TrigLineObj;
TrigLineObj: TYPE = RECORD [
Line equation of the form: y*cos(theta) - x*sin(theta) -d = 0,
where theta is the angle which the line makes with the x axis and d is the distance from the line to the origin.
c: REAL, -- cos(theta)
s: REAL, -- sin(theta)
theta: REAL, -- angle in (-pi..pi]
d: REAL, -- distance from line to origin
slope: REAL, -- slope and yInt are redundant information but they come almost for free.
yInt: REAL
];
Ray2d: TYPE = REF Ray2dObj;
Ray2dObj: TYPE = RECORD [
p: Point2d,
d: Vector2d];
END.