DIRECTORY SV3d, SVSceneTypes; SVSpheres: CEDAR DEFINITIONS = BEGIN Circle3d: TYPE = SV3d.Circle3d; Edge3d: TYPE = SV3d.Edge3d; Line3d: TYPE = SV3d.Line3d; Point3d: TYPE = SV3d.Point3d; Ray: TYPE = SVSceneTypes.Ray; Sphere: TYPE = SV3d.Sphere; Vector3d: TYPE = SV3d.Vector3d; CreateEmptySphere: PROC [] RETURNS [sphere: Sphere]; CopySphere: PROC [from: Sphere, to: Sphere]; FillSphereFromPointAndRadius: PROC [pt: Point3d, radius: REAL, sphere: Sphere]; SphereFromPointAndRadius: PROC [pt: Point3d, radius: REAL] RETURNS [sphere: Sphere]; FillSphereFrom4Points: PROC [p0, p1, p2, p3: Point3d, sphere: Sphere] RETURNS [planar: BOOL]; SphereFrom4Points: PROC [p0, p1, p2: Point3d] RETURNS [sphere: Sphere, planar: BOOL]; SphereMeetsLine: PROC [sphere: Sphere, line: Line3d] RETURNS [points: ARRAY [1..2] OF Point3d, hitCount: [0..2], tangent: BOOL]; SphereMeetsRay: PROC [sphere: Sphere, ray: Ray] RETURNS [points: ARRAY [1..2] OF Point3d, normals: ARRAY [1..2] OF Vector3d, hitCount: [0..2], tangent: BOOL]; SphereMeetsEdge: PROC [sphere: Sphere, edge: Edge3d] RETURNS [points: ARRAY [1..2] OF Point3d, hitCount: [0..2], tangent: BOOL]; SphereMeetsSphere: PROC [sphere1, sphere2: Sphere] RETURNS [circle: Circle3d, dimension: [-1..2]]; SignedSphereDistance: PROC [pt: Point3d, sphere: Sphere] RETURNS [d: REAL]; SphereDistance: PROC [pt: Point3d, sphere: Sphere] RETURNS [d: REAL]; PointProjectedOntoSphere: PROC [pt: Point3d, sphere: Sphere] RETURNS [projectedPt: Point3d]; END. βSVSpheres.mesa Copyright c 1986 by Xerox Corporation. All rights reserved. Last edited by Bier on September 23, 1987 10:59:22 pm PDT Contents: Sphere routines. "sphere" now has center at "point" and radius of "radius". Returns a sphere with center at "point" and radius of "radius". "sphere" now passes through the four points. If the points are roughly coplanar, creates a large sphere passing through p0, p1 and p2. Returns a sphere which passes through the three points. If the points are roughly collinear, creates a large sphere passing through p0, p1 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. "dimension" is the dimension of the intersection: -1 for a miss, 0 for a point of tangency, 1 for a circle of intersection, 2 for coincident spheres. We drop a normal from the point onto the sphere and find where it hits. ΚE˜J˜Icodešœ™Kšœ Οmœ1™