DIRECTORY SV3d, SVModelTypes, SVSceneTypes; SVTransforms: CEDAR DEFINITIONS = BEGIN Camera: TYPE = SVModelTypes.Camera; CoordSystem: TYPE = SVModelTypes.CoordSystem; Matrix4by4: TYPE = SV3d.Matrix4by4; Point3d: TYPE = SV3d.Point3d; Scene: TYPE = SVSceneTypes.Scene; Slice: TYPE = SVSceneTypes.Slice; Vector3d: TYPE = SV3d.Vector3d; AbsTransfScreen: PROC [c: CoordSystem, n: Matrix4by4]; IncTransfMatrix: PUBLIC PROC [c: CoordSystem, dWorld: Matrix4by4, m: Matrix4by4]; AbsTransfMatrix: PROC [c: CoordSystem, dWorld: Matrix4by4, n: Matrix4by4]; Translate: PROC [c: Slice, scene: Scene, vec: Vector3d, d: CoordSystem _ NIL, dFixed: BOOL _ FALSE]; Rotate: PROC [c: Slice, scene: Scene, axis: [1..3], degrees: REAL, d: CoordSystem _ NIL, dFixed: BOOL _ FALSE]; PlaneOriginRotate: PROC [c: CoordSystem, d: CoordSystem, degrees: REAL, plane: NAT]; Align: PROC [c: Slice, scene: Scene, d: CoordSystem]; Abut: PROC [c: Slice, scene: Scene, d: CoordSystem]; AbutAxis: PROC [c: Slice, scene: Scene, axis: [1..3], d: CoordSystem]; AbsTranslateOnly: PROC [c: Slice, scene: Scene, d: CoordSystem, vD: Point3d]; NormalizeRot: PROC [c: Slice, scene: Scene, d: CoordSystem]; Normalize: PROC [c: Slice, scene: Scene, d: CoordSystem]; NormalizeRotTug: PROC [c: Slice, scene: Scene, tugBoat: Slice, d: CoordSystem]; NormalizeTug: PROC [c: Slice, scene: Scene, tugBoat: Slice, d: CoordSystem]; AlignTug: PROC [c: Slice, scene: Scene, tugBoat: Slice, d: CoordSystem]; AbutTug: PROC [c: Slice, scene: Scene, tugBoat: Slice, d: CoordSystem]; AbutTugAxis: PROC [c: Slice, scene: Scene, axis: [1..3], tugBoat: Slice, d: CoordSystem]; DirtyAssembly: PROC [a: Slice]; TidyUpCoordSysTree: PROC [root: CoordSystem]; ScalePrimitives: PROC [a: Slice, sx, sy, sz: REAL]; ScaleEven: PROC [a: Slice, scene: Scene, scalar: REAL, d: CoordSystem _ NIL]; ScaleEvenChildren: PROC [a: Slice, scene: Scene, scalar: REAL, d: CoordSystem _ NIL]; AssemblyHasNoChildren: ERROR; ScaleDistancesChildren: PROC [c: Slice, scene: Scene, sx, sy, sz: REAL, d: CoordSystem _ NIL]; Scale: PROC [c: Slice, scene: Scene, sx, sy, sz: REAL, d: CoordSystem _ NIL]; END. File: SVTransforms.mesa Last edited by Bier on June 1, 1984 2:55:30 pm PDT Author: Eric Bier on June 2, 1987 4:42:25 pm PDT Contents: Procedures for Scaling, Translating, and Rotating assemblies with respect to an arbitrary coordinate system A set of routines which call IncTransf: Rotates C about an axis parallel to the plane axis of D, passing thru the origin of C. A set of routines which call AbsTransf: Places C so that the rotation from C to D remains as it is, but the translation is set to vD. Leave translation between C and D as is. The axes of C become parallel to the axes of D. C becomes identical to D. A set of routines which specialize TugTransf: The three procs below are like their lookalikes above. The difference is one level of indirection. AbutIndirect doesn't put assembly's coordSys on top of dock. Instead, it puts tugBoat on top of dock, where the relationship between a and tugBoat remains constant. Routines for updating cached matrices: This assembly has moved. Mark its coordinate system and those of its children as dirty. Walk the coordsys tree. For each component of each coordsystem matrix, if the component is almost a multiple of .5, make it exactly so. TellAboutCameraAndWorld: PROC [root: CoordSystem, camera: Camera]; Tree walk through the tree and concatenate all matrices (will later concatenate matrices as it goes). This computes values for intermediate matrices as well as primitive matrices. Can be started using any assembly as root. TellAboutParent: PROC [cs: CoordSystem]; Updates the wrtWorld, and wrtCamera fields of cs by premultiplying cs.mat by cs.withRespectTo.wrtWorld and cs.withRespectTo.wrtCamera respectively. Scaling operations (IncTransf derivatives but more complicated). There are five ways to scale a cluster assembly 1) (ScalePrimitives) Scale each primitive in place, evenly or differentially. 2) (ScaleEven) If sx = sy = sz. Scale primitives in place and then translate all intermediate assemblies so the cluster assembly scales evenly as a unit 3) (ScaleNoShear) IF sx # sy or sy # sz. Scale the primitives evenly so that their dimension in the direction of scaling increases or decreases to the same quantity it would have reached by method 3. This preserves shape of primitives. Global shape is not preserved (but almost). 4) (ScaleEvenChildren) Perform a ScaleEven on each of the children of the cluster assembly but leave their relative translations fixed. This is equivalent to performing a ScaleEven (child, child's cs, scalar) on each child individually. 5) (ScaleDistancesChildren) Doesn't change the size or shape of any of the children of assembly. Simply translates all of the children as they would be translated by a Scale even of assembly. ScalePrimitive: PROC [a: Slice, sx, sy, sz: REAL]; May signal AssemblyHasNoChildren. Κ\˜Iheadšœ™Jšœ2™2Jšœ0™0Jšœu™uJ˜šΟk ˜ Jšœ!˜!—J˜Jšœœ˜!Jš˜˜Jšœœ˜#Jšœ œ˜-Jšœ œ˜#Jšœ œ˜Jšœœ˜!Jšœœ˜!Jšœ œ˜J˜—JšΟnœœ!˜6JšžœœœΟuœ˜QJšžœœŸœ˜J˜J˜—Jšœž œ™'J˜Jš ž œœ:œ œœ˜dJš žœœ1œœ œœ˜ošžœœ+œ œ˜TJ™V—J˜Jšœž œ™'J™Jšžœœ*˜5Jšžœœ*˜4Jšžœœ8˜Fprocšžœœ7˜MLšœ]™]—šž œœ*˜