-- compile COGSpace DIRECTORY COGRandom USING [Toss], Real USING [SqRt]; COGSpace: CEDAR DEFINITIONS IMPORTS COGRandom, Real = BEGIN OPEN Rand: COGRandom, Real; Point: TYPE = RECORD [x, y, z: REAL]; Vector: TYPE = Point; Box: TYPE = RECORD [min, max: Point]; Add: PROC [a, b: Vector] RETURNS [Vector] = INLINE {RETURN [[a.x+b.x, a.y+b.y, a.z+b.z]]}; Sub: PROC [a, b: Vector] RETURNS [Vector] = INLINE {RETURN [[a.x-b.x, a.y-b.y, a.z-b.z]]}; Mul: PROC [a: REAL, u: Vector] RETURNS [w: Vector] = INLINE {RETURN [[u.x*a, u.y*a, u.z*a]]}; Way: PROC [alpha: REAL, p, q: Point] RETURNS [Point] = INLINE {beta: REAL = (1.0-alpha); RETURN [[beta*p.x+alpha*q.x, beta*p.y+alpha*q.y, beta*p.z+alpha*q.z]]}; Dot: PROC [u, v: Vector] RETURNS [REAL] = INLINE {RETURN [u.x*v.x+u.y*v.y+u.z*v.z]}; XYRot: PROC [u: Vector, c, s: REAL] RETURNS [ur: Vector] = INLINE {RETURN [[c*u.x-s*u.y, c*u.y+s*u.x, u.z]]}; YZRot: PROC [u: Vector, c, s: REAL] RETURNS [ur: Vector] = INLINE {RETURN [[u.x, c*u.y-s*u.z, c*u.z+s*u.y]]}; ZXRot: PROC [u: Vector, c, s: REAL] RETURNS [ur: Vector] = INLINE {RETURN [[c*u.x+s*u.z, u.y, c*u.z-s*u.x]]}; DoubleRot: PROC [u, v: Vector, c, s: REAL] RETURNS [ur, vr: Vector]; NMirror: PROC [u, n: Vector] RETURNS [um: Vector] = INLINE {RETURN [Sub [u, Mul [2.0*Dot[u, n]/Dot[n, n], n]]]}; Transf: PROC [u, xb, yb, zb: Vector] RETURNS [ut: Vector]; Length: PROC [v: Vector] RETURNS [REAL] = TRUSTED INLINE {RETURN [SqRt[v.x*v.x+v.y*v.y+v.z*v.z]]}; LengthSq: PROC [v: Vector] RETURNS [REAL] = INLINE {RETURN [v.x*v.x+v.y*v.y+v.z*v.z]}; Dist: PROC [p, q: Point] RETURNS [REAL] = INLINE {RETURN [Length[Sub[p,q]]]}; Random: PROC [box: Box] RETURNS [v: Vector] = INLINE {RETURN [ [Rand.Toss [box.min.x, box.max.x], Rand.Toss [box.min.y, box.max.y], Rand.Toss [box.min.z, box.max.z]] ]}; END... ΐ-- COGSpace.mesa: Basic geometrical operations in cartesian three-space -- last modified by Stolfi - September 29, 1982 8:09 pm -- BASIC DATA TYPES - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- PROCEDURES FOR POINTS AND VECTORS - - - - - - - - - - - - - - - - - - - - - - - - - - -- Adds two vectors (or points). -- Subtracts vector b from vector a. -- Multiplies the vector u by a real number a. -- Computes the point alpha the way from u to v. -- Dot product of u and v. -- Rotates the vector u around the z-axis by an angle whose cosine is c and whose sine is s. -- Rotates the vector u around the x-axis by an angle whose cosine is c and whose sine is s. -- Rotates the vector u around the y-axis by an angle whose cosine is c and whose sine is s. -- Rotates the vectors u in their own plane by an angle whose cosine is c and whose sine is s. Note: If the lengths of u and v are different, the angle is measured "elliptically". -- Mirrors the vector u about the plane whose normal is n (which should have nonzero length). -- Post-multiplies the vector u by the 3x3 array whose lines are xv, yv and zv. That is, returns the vector u.x*xb+u.y*yb+u.z*zb. -- Length of vector v. -- Length of vector v, squared (saves a square root extraction). -- Distance between points p and q. Returns LargestNumber if one point is infinite, and TrappingNaN if both are infinite or one is indeterminate. -- Returns a random vector in the given box. ΚE– "Mesa" style˜IprocšΟcΠbc 7™GKš7™7Kš˜KšΟk œ Ÿœ˜8KšΟbœŸœŸ œŸœ˜7KšŸœŸœ˜!K˜KšR™RKš œŸœŸœ Ÿœ˜%Kš œŸœ ˜Kš œŸœŸœ˜%K˜KšY™YK˜šΟnœŸœŸœ Ÿ˜2Kš ™ KšœŸœ ˜'—K˜š‘œŸœŸœ Ÿ˜2Kš$™$KšœŸœ ˜'—K˜š ‘œŸœŸœ ŸœŸ˜;Kš.™.KšœŸœ˜"—K˜š ‘œŸœ ŸœŸœ Ÿ˜=Kš0™0KšœŸœŸœA˜c—K˜š ‘œŸœŸœŸœŸ˜0Kš™KšœŸœ˜#—K˜š‘œŸœŸœŸ˜AKš]™]KšœŸœ$˜+—K˜š‘œŸœŸœŸ˜AKš]™]KšœŸœ$˜+—K˜š‘œŸœŸœŸ˜AKš]™]KšœŸœ$˜+—K˜š‘ œŸœŸœŸ˜DKšeœP™Ά—K˜š‘œŸœŸœ Ÿ ˜:Kš^™^KšœŸœ.˜5—K˜š‘œŸœŸœ Ÿ˜:Kš™—š ‘œŸœ ŸœŸœŸœŸ˜9Kš™KšœŸœ"˜)—K˜š ‘œŸœ ŸœŸœŸ˜2Kš@™@KšœŸœ˜#—K˜š ‘œŸœŸœŸœŸ˜0Kš‘™‘KšœŸœ˜—K˜š‘œŸœ ŸœŸ˜4Kš,™,KšœŸœx˜—KšŸœ˜J˜—…—*/