SVSpheres.mesa
Copyright © 1986 by Xerox Corporation. All rights reserved.
Last edited by Bier on September 23, 1987 10:59:22 pm PDT
Contents: Sphere routines.
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];
"sphere" now has center at "point" and radius of "radius".
SphereFromPointAndRadius:
PROC [pt: Point3d, radius:
REAL]
RETURNS [sphere: Sphere];
Returns a sphere with center at "point" and radius of "radius".
FillSphereFrom4Points:
PROC [p0, p1, p2, p3: Point3d, sphere: Sphere]
RETURNS [planar:
BOOL];
"sphere" now passes through the four points. If the points are roughly coplanar, creates a large sphere passing through p0, p1 and p2.
SphereFrom4Points:
PROC [p0, p1, p2: Point3d]
RETURNS [sphere: Sphere, planar:
BOOL];
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.
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];
If there is a single point of intersection, then tangent will be TRUE.
SphereMeetsEdge:
PROC [sphere: Sphere, edge: Edge3d]
RETURNS [points:
ARRAY [1..2]
OF Point3d, hitCount: [0..2], tangent:
BOOL];
If there is a single point of intersection, then tangent will be TRUE iff that point of intersection is a point of tangency.
SphereMeetsSphere:
PROC [sphere1, sphere2: Sphere]
RETURNS [circle: Circle3d, dimension: [-1..2]];
"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.
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];
We drop a normal from the point onto the sphere and find where it hits.
END.