DIRECTORY GGBasicTypes, Lines2dTypes; GGCircles: CEDAR DEFINITIONS = BEGIN Arc: TYPE = GGBasicTypes.Arc; Circle: TYPE = GGBasicTypes.Circle; Point: TYPE = Lines2dTypes.Point; Edge: TYPE = Lines2dTypes.Edge; Line: TYPE = Lines2dTypes.Line; Vector: TYPE = GGBasicTypes.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]; FillCircleFrom3Points: PROC [p0, p1, p2: Point, circle: Circle] RETURNS [linear: BOOL]; CircleFrom3Points: PROC [p0, p1, p2: Point] RETURNS [circle: Circle, linear: BOOL]; CircleMeetsLine: PROC [circle: Circle, line: Line] RETURNS [points: ARRAY [1..2] OF Point, hitCount: [0..2], tangent: BOOL]; CircleMeetsEdge: PROC [circle: Circle, edge: Edge] RETURNS [points: ARRAY [1..2] OF Point, hitCount: [0..2], tangent: BOOL]; CircleMeetsCircle: PROC [circle1, circle2: Circle] RETURNS [points: ARRAY [1..2] OF Point, hitCount: [0..2], tangent: BOOL]; CircleMeetsArc: PROC [circle: Circle, arc: Arc] RETURNS [points: ARRAY [1..2] OF Point, hitCount: [0..2], tangent: BOOL]; ArcMeetsLine: PROC [arc: Arc, line: Line] RETURNS [points: ARRAY [1..2] OF Point, hitCount: [0..2], tangent: BOOL]; ArcMeetsEdge: PROC [arc: Arc, edge: Edge] RETURNS [points: ARRAY [1..2] OF Point, hitCount: [0..2], tangent: BOOL]; ArcMeetsArc: PROC [arc1, arc2: Arc] RETURNS [points: ARRAY [1..2] OF Point, hitCount: [0..2], tangent: 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]; PointIsInCircle: PROC [pt: Point, circle: Circle] RETURNS [BOOL]; CreateEmptyArc: PROC RETURNS [arc: Arc]; CopyArc: PROC [from: Arc, to: Arc]; FillArc: PROC [v0, v1, v2: Point, arc: Arc]; CreateArc: PROC [v0, v1, v2: Point] RETURNS [arc: Arc]; ReverseArc: PROC [arc: 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]; OnArc: PROC [pt: Point, arc: Arc] RETURNS [BOOL]; END. ΔGGCircles.mesa Author: Eric Bier on June 4, 1985 4:58:33 pm PDT Last edited by Bier on July 16, 1987 1:23:18 pm PDT Contents: Routines for finding the intersections of various types of circles, lines, and points. Pier, May 22, 1987 10:32:29 am PDT Bier, May 8, 1989 12:16:55 pm PDT Circles Since circles are fairly large data structures, you may prefer to allocate one with CreateEmptyCircle and repeatedly fill it with new data instead of allocating a new one each time. "circle" now has center at "pt" and radius of "radius". Returns a circle with center at "pt" and radius of "radius". "circle" now passes through the three points. If the points are roughly collinear, creates a large circle passing through p0 and p2. Returns a circle which passes through the three points. If the points are roughly collinear, creates a large circle passing through p0 and p2. If there is a single point of intersection, then tangent will be TRUE. If there is a single point of intersection, then tangent will be TRUE iff that point of intersection is a point of tangency. If there is a single point of intersection, then tangent will be TRUE iff that point of intersection is a point of tangency. If there is a single point of intersection, then tangent will be TRUE iff that point of intersection is a point of tangency. If there is a single point of intersection, then tangent will be TRUE iff that point of intersection is a point of tangency. If there is a single point of intersection, then tangent will be TRUE iff that point of intersection is a point of tangency. If there is a single point of intersection, then tangent will be TRUE iff that point of intersection is a point of tangency. 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 If the arc is now clockwise, make it counter-clockwise and vice-versa. This also swaps the values of p0 and p2. Assumes pt is on arc.circle. Is it on arc? The nearest point on arc.circle to pt, if the nearest point is on arc. Otherwise, the nearest endpoint. Distance[pt, NearestPointOnArc[pt, arc]]. Κ˜Icode™KšΟnœ'Οk™0Kšœ3™3šœY™aKšœž™"K™!—K˜šž ˜ Kšœ˜—K˜Kš œžœž œ˜Kšž˜˜Kšœžœ˜Kšœžœ˜#Kšœžœ˜!Kšœžœ˜Kšœžœ˜Kšœžœ˜#K˜K˜—K™K™K˜Kšœžœžœ˜4Kš œžœ˜-˜Kšœ΅™΅K™—šœžœžœ˜NKšœ7™7—šœžœžœžœ˜SKšœ<™<—K˜šœžœ&žœ žœ˜XK™…—šœžœžœžœ˜SKšœ™—K˜K˜š œžœžœ žœžœ#žœ˜}KšœAžœ™F—š œžœžœ žœžœ#žœ˜}KšœAžœ7™|—š œžœžœ žœžœ#žœ˜}KšœAžœ7™|—š œžœžœ žœžœ#žœ˜yKšœAžœ7™|—š  œžœžœ žœžœ#žœ˜sKšœAžœ7™|—š  œžœžœ žœžœ#žœ˜sKšœAžœ7™|—š  œžœžœ žœžœ#žœ˜mKšœAžœ7™|—K˜Kšœžœžœžœ˜JKšœžœžœžœ˜DKšœžœžœ˜YKšœžœžœžœ˜B˜šœD™DKšœR™R—K™+K™%K˜—K™K™K˜Kšœžœžœ ˜)Kšœžœ˜$K˜Kšœžœ ˜-Kš œžœžœ ˜8š œžœ ˜K™p—K˜šœžœžœžœ˜=Kšœ+™+—Kšœžœžœ˜GKš œžœžœžœ˜]šœžœžœ˜EKšœh™hK™—šœžœžœ žœ˜IKšœ)™)—Kšœžœžœžœ˜WKšœžœžœžœ˜1K™Kšžœ˜K˜—…— &ό