DIRECTORY SV3d; SVLines3d: CEDAR DEFINITIONS = BEGIN Edge3d: TYPE = SV3d.Edge3d; Line3d: TYPE = SV3d.Line3d; Matrix4by4: TYPE = SV3d.Matrix4by4; Point3d: TYPE = SV3d.Point3d; Vector3d: TYPE = SV3d.Vector3d; CreateEmptyLine: PROC RETURNS [line: Line3d]; CopyLine: PROC [from: Line3d, to: Line3d]; LineFromPoints: PROC [v1, v2: Point3d] RETURNS [line: Line3d]; LineFromPointAndVector: PROC [pt: Point3d, vec: Vector3d] RETURNS [line: Line3d]; LineNormalToLineThruPoint: PROC [line: Line3d, pt: Point3d] RETURNS [normalLine: Line3d]; FillLineFromPoints: PROC [v1, v2: Point3d, line: Line3d]; FillLineFromPointAndVector: PROC [pt: Point3d, vec: Vector3d, line: Line3d]; FillLineNormalToLineThruPoint: PROC [line: Line3d, pt: Point3d, normalLine: Line3d]; CreateEmptyEdge: PROC RETURNS [edge: Edge3d]; CopyEdge: PROC [from: Edge3d, to: Edge3d]; CreateEdge: PROC [v1, v2: Point3d] RETURNS [edge: Edge3d]; EdgeTransform: PROC [fixed: Edge3d, transform: Matrix4by4] RETURNS [edge: Edge3d]; FillEdge: PROC [v1, v2: Point3d, edge: Edge3d]; FillEdgeTransform: PROC [fixed: Edge3d, transform: Matrix4by4, edge: Edge3d]; DirectionOfLine: PROC [line: Line3d] RETURNS [direction: Vector3d]; DistancePointToLine: PROC [pt: Point3d, line: Line3d] RETURNS [d: REAL]; DistanceLineToLine: PROC [l1, l2: Line3d] RETURNS [d: REAL]; DropPerpendicular: PROC [pt: Point3d, line: Line3d] RETURNS [projectedPt: Point3d]; NearEndpointToPoint: PROC [pt: Point3d, edge: Edge3d] RETURNS [endpoint: Point3d]; Distance2PointToEndpoint: PROC [pt: Point3d, edge: Edge3d] RETURNS [distanceSquared: REAL]; NearEdgePointToPoint: PROC [pt: Point3d, edge: Edge3d] RETURNS [onEdge: Point3d]; Distance2PointToEdge: PROC [pt: Point3d, edge: Edge3d] RETURNS [distanceSquared: REAL]; DistancePointToEdge: PROC [pt: Point3d, edge: Edge3d] RETURNS [distance: REAL]; OnEdge: PROC [pt: Point3d, edge: Edge3d] RETURNS [BOOL]; LinePointOnEdge: PROC [pt: Point3d, edge: Edge3d] RETURNS [BOOL]; DistanceLineToEdge: PROC [line: Line3d, edge: Edge3d] RETURNS [distance: REAL]; NearEdgePointToLine: PROC [line: Line3d, edge: Edge3d] RETURNS [edgePoint: Point3d]; DistanceAndPointLineToEdge: PROC [line: Line3d, edge: Edge3d] RETURNS [distance: REAL, edgePoint: Point3d]; END. ΒSVLines3d.mesa Copyright c 1986 by Xerox Corporation. All rights reserved. Last edited by Bier on February 18, 1987 Contents: Procedures for performing geometric operations on lines and points in 3-space. Making Lines These procedures allocate a new Line3d. line and pt determine a plane. Within that plane, compute the line that is perpendicular to line and passes throught pt. 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. line and pt determine a plane. Within that plane, compute the line that is perpendicular to line and passes throught pt. Making Edges These procedures allocate a new edge. Since Edges are fairly large data structures, you may prefer to allocate one with CreateEmptyEdge and repeatedly fill it with new data instead of allocating a new one each time. Direction and Distance for Lines Returns the unit direction vector of 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 using FillLineNormalToLineThruPoint above. Distance for Edges Comparing Edges to Points Computes the distance to each of the two endpoints and takes the smaller of the two. Drop a perpendicular to the line of the edge. If the resulting point is on the edge, use it. Otherwise, find the nearest endpoint. DistanceSquared[pt, NearestPointOnEdge[pt, edge]]. Returns TRUE if pt is within a very small distance from edge. Assumes pt is on the line that includes edge. Is it on edge itself? Square root of the above. Comparing Edges to Lines I compute them both anyway, so if you need both, this will be faster. Κ#˜J˜Icodešœ™Kšœ Οmœ1™KšžœŸœŸœ˜RšžœŸœŸœ˜YK™yK™—Kšœ±™±KšžœŸœ!˜9KšžœŸœ,˜LšžœŸœ1˜TK™y—L™ KšžœŸœŸœ˜.KšžœŸœ˜+˜K™%—Kšž œŸœŸœ˜;šž œŸœ(Ÿœ˜RK™Kšœ±™±—KšžœŸœ"˜0KšžœŸœ6˜ML™ šžœŸœŸœ˜CK™*—KšžœŸœŸœŸœ˜IKšžœŸœŸœŸœ˜