DIRECTORY GGModelTypes; GGCircles: CEDAR DEFINITIONS = BEGIN Arc: TYPE = GGModelTypes.Arc; Circle: TYPE = GGModelTypes.Circle; Point: TYPE = GGModelTypes.Point; Edge: TYPE = GGModelTypes.Edge; Line: TYPE = GGModelTypes.Line; Vector: TYPE = GGModelTypes.Vector; CreateEmptyCircle: PROC [] RETURNS [circle: Circle]; CopyCircle: PROC [from: Circle, to: Circle]; FillCircleFromPointAndRadius: PROC [pt: Point, radius: REAL, circle: Circle]; CircleFromPointAndRadius: PROC [pt: Point, radius: REAL] RETURNS [circle: Circle]; LineMeetsCircle: PROC [line: Line, circle: Circle] RETURNS [points: ARRAY [1..2] OF Point, hitCount: [0..2]]; CircleMeetsCircle: PROC [circle1, circle2: Circle] RETURNS [points: ARRAY [1..2] OF Point, hitCount: [0..2]]; CircleMeetsEdge: PROC [circle: Circle, edge: Edge] RETURNS [intersection: Point, miss: BOOL]; SignedCircleDistance: PROC [pt: Point, circle: Circle] RETURNS [d: REAL]; CircleDistance: PROC [pt: Point, circle: Circle] RETURNS [d: REAL]; PointProjectedOntoCircle: PROC [pt: Point, circle: Circle] RETURNS [projectedPt: Point]; CreateArc: PROC [v1, v2: Point] RETURNS [arc: Arc]; CreateEmptyArc: PROC RETURNS [arc: Arc]; FillArc: PROC [v1, v2: Point, arc: Arc]; CopyArc: PROC [from: Arc, to: Arc]; CirclePointOnArc: PROC [pt: Point, arc: Arc] RETURNS [BOOL]; NearestEndpoint: PROC [pt: Point, arc: Arc] RETURNS [endpoint: Point]; DistanceSquaredToNearestEndpoint: PROC [pt: Point, arc: Arc] RETURNS [distanceSquared: REAL]; NearestPointOnArc: PROC [pt: Point, arc: Arc] RETURNS [onArc: Point]; DistancePointToArc: PROC [pt: Point, arc: Arc] RETURNS [distance: REAL]; DistanceSquaredPointToArc: PROC [pt: Point, arc: Arc] RETURNS [distanceSquared: REAL]; END. ŒGGCircles.mesa Author: Eric Bier on June 4, 1985 4:58:33 pm PDT Last edited by Bier on August 16, 1985 1:30:24 pm PDT Contents: Routines for finding the intersections of various types of circles, lines, and points. Circles 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. Arcs 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. Κ™˜Ihead1™Iprocšœ0™0Lšœ5™5Lšœa™aL˜šΟk ˜ Lšœ ˜ —L˜Lšœ œ œ˜Lš˜L˜Lšœœ˜Lšœœ˜#Lšœœ˜!Lšœœ˜Lšœœ˜šœœ˜#L˜L˜—L™L™L˜LšΟnœœœ˜4Lšž œœ˜-˜Lšœ±™±—Lšžœœœ˜N˜L™$—Lšžœœœœ˜SL˜Lš žœœœ œœ˜nLš žœœœ œœ˜nL˜Lšžœœœœ˜^Lšžœœœœ˜JLšžœœœœ˜Dšžœœœ˜YšœD™DLšœR™R—L™+L™%L˜—L™J™L˜Lšž œœœ ˜4Lšžœœœ ˜)Lšžœœ˜)Lšžœœ˜$šžœœœœ˜=Lšœ+™+—Lšžœœœ˜GLšž œœœœ˜]šžœœœ˜ELšœi™i—šžœœœ œ˜ILšœF™F—Lšžœœœœ˜WL™Lšœ˜J˜—…—ΐ ε