DIRECTORY GGModelTypes; GGLines: CEDAR DEFINITIONS = BEGIN Point: TYPE = GGModelTypes.Point; Edge: TYPE = GGModelTypes.Edge; Line: TYPE = GGModelTypes.Line; Ray: TYPE = GGModelTypes.Ray; Vector: TYPE = GGModelTypes.Vector; CreateEmptyLine: PROC RETURNS [line: Line]; CopyLine: PROC [from: Line, to: Line]; FillLineFromPoints: PROC [v1, v2: Point, line: Line]; FillLineFromPointAndVector: PROC [pt: Point, vec: Vector, line: Line]; FillLineFromCoefficients: PROC [sineOfTheta, cosineOfTheta, distance: REAL, line: Line]; FillLineFromPointAndAngle: PROC [pt: Point, degrees: REAL, line: Line]; FillLineAsNormal: PROC [line: Line, pt: Point, normalLine: Line]; FillLineLeftOfLine: PROC [line: Line, dist: REAL, parallelLine: Line]; FillLineRightOfLine: PROC [line: Line, dist: REAL, parallelLine: Line]; LineFromPoints: PROC [v1, v2: Point] RETURNS [line: Line]; LineFromPointAndVector: PROC [pt: Point, vec: Vector] RETURNS [line: Line]; LineFromCoefficients: PROC [sineOfTheta, cosineOfTheta, distance: REAL] RETURNS [line: Line]; LineFromPointAndAngle: PROC [pt: Point, degrees: REAL] RETURNS [line: Line]; LineNormalToLineThruPoint: PROC [line: Line, pt: Point] RETURNS [normalLine: Line]; LineLeftOfLine: PROC [line: Line, dist: REAL] RETURNS [parallelLine: Line]; LineRightOfLine: PROC [line: Line, dist: REAL] RETURNS [parallelLine: Line]; LineMeetsLine: PROC [line1, line2: Line] RETURNS [intersection: Point, parallel: BOOL]; LineMeetsYAxis: PROC [line: Line] RETURNS [yInt: REAL, parallel: BOOL]; LineMeetsEdge: PROC [line: Line, edge: Edge] RETURNS [intersection: Point, noHit: BOOL]; SignedLineDistance: PROC [pt: Point, line: Line] RETURNS [d: REAL]; LineDistance: PROC [pt: Point, line: Line] RETURNS [d: REAL]; PointProjectedOntoLine: PROC [pt: Point, line: Line] RETURNS [projectedPt: Point]; PointOnLine: PROC [line: Line] RETURNS [pt: Point]; DirectionOfLine: PROC [line: Line] RETURNS [direction: Vector]; CreateEdge: PROC [v1, v2: Point] RETURNS [edge: Edge]; CreateEmptyEdge: PROC RETURNS [edge: Edge]; FillEdge: PROC [v1, v2: Point, edge: Edge]; CopyEdge: PROC [from: Edge, to: Edge]; LinePointOnEdge: PROC [pt: Point, edge: Edge] RETURNS [BOOL]; NearestEndpoint: PROC [pt: Point, edge: Edge] RETURNS [endpoint: Point]; DistanceSquaredToNearestEndpoint: PUBLIC PROC [pt: Point, edge: Edge] RETURNS [distanceSquared: REAL]; NearestPointOnEdge: PROC [pt: Point, edge: Edge] RETURNS [onEdge: Point]; DistancePointToEdge: PROC [pt: Point, edge: Edge] RETURNS [distance: REAL]; DistanceSquaredPointToEdge: PROC [pt: Point, edge: Edge] RETURNS [distanceSquared: REAL]; DistancePointToPoint: PROC [p1, p2: Point] RETURNS [distance: REAL]; DistanceSquaredPointToPoint: PROC [p1, p2: Point] RETURNS [distance: REAL]; PointLeftOfLine: PROC [distance: REAL, pOnLine: Point, line: Line] RETURNS [point: Point]; CreateRay: PROC [basePoint: Point, direction: Vector] RETURNS [ray: Ray]; CreateRayFromPoints: PROC [p1, p2: Point] RETURNS [ray: Ray]; LineRayMeetsBox: PROC [ray: Ray, xmin, ymin, xmax, ymax: REAL] RETURNS [count: NAT, params: ARRAY[1..2] OF REAL]; EvalRay: PROC [ray: Ray, param: REAL] RETURNS [point: Point]; END. ΪGGLines.mesa Author: Eric Bier on June 4, 1985 4:58:33 pm PDT Last edited by Bier on October 1, 1985 5:31:09 pm PDT Contents: Routines for finding the intersections of various types of lines and line segments Lines Since lines are fairly large data structures, you may prefer to allocate one with CreateEmptyLine and repeatedly fill it with new data instead of allocating a new one each time. This procedures allocate a new Line. We drop a normal from the point onto the line and find where it hits the line equation of the normal we drop can be found as in FillLineAsNormal above. Finds any old point on line and returns it. Returns the direction vector of line. Edges Assumes pt is on edge.line. Is it on edge? Faster than DistancePointToPoint[pt, NearestEndpoint[pt, edge]] (if you don't care what the endpoint is). Perpendicular distance if possible, else distance to nearest endpoint. Points RAYS -- Used by GGShapes to draw infinite lines (e.g. to do manual clipping) Κ.˜Ihead1™ Iprocšœ0™0Lšœ5™5Lšœ]™]L˜šΟk ˜ Lšœ ˜ —L˜Lšœ œ œ˜Lš˜L˜Lšœœ˜!Lšœœ˜Lšœœ˜Lšœœ˜šœœ˜#L˜L˜—L™L˜LšΟnœœœ˜,Lšžœœ˜'˜Lšœ±™±—Lšžœœ˜6Lšžœœ'˜GLšžœœ)œ˜YLšžœœœ˜HLšžœœ,˜BLšžœœœ˜FLšžœœœ˜G˜L™$—Lšžœœœ˜;Lšžœœœ˜LLšžœœ)œœ˜^Lšžœœœœ˜MLšžœœœ˜TLšžœœœœ˜KLšžœœœœ˜LL˜Lšž œœœ!œ˜XLš žœœœœ œ˜HLšž œœœœ˜YLšžœœœœ˜DLšž œœœœ˜>šžœœœ˜SšœD™DLšœR™R——šž œœœ ˜3L™+—šžœœœ˜?L™%L˜—L™™L˜—L˜Lšž œœœ˜7Lšžœœœ˜,Lšžœœ˜,Lšžœœ˜'šžœœœœ˜>Lšœ+™+—Lšžœœœ˜ILš ž œœœœœ˜fšžœœœ˜ILšœi™i—šžœœœ œ˜LLšœF™F—Lšžœœœœ˜ZL™L™™L˜—Lšžœœœ œ˜ELšžœœœ œ˜LLšžœœ œœ˜[L˜LšœL™LL˜Lšž œœ'œ ˜ILšžœœœ ˜=Lšžœœ$œœ œ œœœ˜qLšžœœœœ˜=L˜Lšœ˜—…— nv