DIRECTORY SV3d, SVModelTypes, SVSceneTypes; SVTransforms: DEFINITIONS = BEGIN Assembly: TYPE = SVSceneTypes.Assembly; Camera: TYPE = SVModelTypes.Camera; CoordSystem: TYPE = SVModelTypes.CoordSystem; Matrix4by4: TYPE = SV3d.Matrix4by4; Point3d: TYPE = SV3d.Point3d; Scene: TYPE = SVSceneTypes.Scene; IncTransf: PROC [C: CoordSystem, D: CoordSystem, M: Matrix4by4, DFixed: BOOL _ FALSE]; AbsTransf: PROC [C: CoordSystem, D: CoordSystem, N: Matrix4by4, DFixed: BOOL _ FALSE]; TugTransf: PROC [C: CoordSystem, tugBoat: CoordSystem, D: CoordSystem, N: Matrix4by4]; TugTransfLeaveTug: PROC [C: CoordSystem, tugBoat: CoordSystem, D: CoordSystem, N: Matrix4by4]; Translate: PROC [C: CoordSystem, D: CoordSystem, tx, ty, tz: REAL, DFixed: BOOL _ FALSE]; XRotate: PROC [C: CoordSystem, D: CoordSystem, degrees: REAL, DFixed: BOOL _ FALSE]; YRotate: PROC [C: CoordSystem, D: CoordSystem, degrees: REAL, DFixed: BOOL _ FALSE]; ZRotate: PROC [C: CoordSystem, D: CoordSystem, degrees: REAL, DFixed: BOOL _ FALSE]; PlaneOriginRotate: PROC [C: CoordSystem, D: CoordSystem, degrees: REAL, plane: NAT]; Align: PROC [C: CoordSystem, D: CoordSystem]; Abut: PROC [C: CoordSystem, D: CoordSystem]; AbutX: PROC [C: CoordSystem, D: CoordSystem]; AbutY: PROC [C: CoordSystem, D: CoordSystem]; AbutZ: PROC [C: CoordSystem, D: CoordSystem]; AbsTranslateOnly: PROC [C: CoordSystem, D: CoordSystem, vD: Point3d]; NormalizeRot: PROC [C: CoordSystem, D: CoordSystem]; Normalize: PROC [C: CoordSystem, D: CoordSystem]; NormalizeRotTug: PROC [C: CoordSystem, tugBoat: CoordSystem, D: CoordSystem]; NormalizeTug: PROC [C: CoordSystem, tugBoat: CoordSystem, D: CoordSystem]; AlignTug: PROC [C: CoordSystem, tugBoat: CoordSystem, D: CoordSystem]; AbutTug: PROC [C: CoordSystem, tugBoat: CoordSystem, D: CoordSystem]; AbutXTug: PROC [C: CoordSystem, tugBoat: CoordSystem, D: CoordSystem]; AbutYTug: PROC [C: CoordSystem, tugBoat: CoordSystem, D: CoordSystem]; AbutZTug: PROC [C: CoordSystem, tugBoat: CoordSystem, D: CoordSystem]; DirtyAssembly: PROC [a: Assembly]; TidyUpCoordSysTree: PROC [root: CoordSystem]; TellAboutCameraAndWorld: PROC [root: CoordSystem, camera: Camera, scene: Scene]; TellAboutParent: PROC [cs: CoordSystem]; ScalePrimitive: PROC [a: Assembly, sx, sy, sz: REAL]; ScalePrimitives: PROC [a: Assembly, sx, sy, sz: REAL]; ScaleEven: PROC [a: Assembly, cs: CoordSystem, scalar: REAL]; ScaleEvenChildren: PROC [a: Assembly, cs: CoordSystem, scalar: REAL]; AssemblyHasNoChildren: ERROR; ScaleDistancesChildren: PROC [a: Assembly, cs: CoordSystem, sx, sy, sz: REAL]; ScaleNoShear: PROC [a: Assembly, cs: CoordSystem, sx, sy, sz: REAL]; Scale: PROC [a: Assembly, cs: CoordSystem, sx, sy, sz: REAL]; END. <File: SVTransforms.mesa Last edited by Bier on June 1, 1984 2:55:30 pm PDT Author: Eric Bier on January 4, 1985 6:05:28 pm PST Contents: Procedures for Scaling, Translating, and Rotating assemblies with respect to an arbitrary coordinate system The three routines suggested in "Pointing and Placing with Homogeneous Coordinates", submitted to Computer Vision, Graphics, and Image Processing: Incrementally transform C with respect to D by M. If D is a descendent of C, this could result in D moving as well. If this is not desired, set DFixed to TRUE and IncTransf makes sure that D doesn't move. Absolutely transform C with respect to D by M. If D is a descendent of C, this could result in D moving as well. If this is not desired, set DFixed to TRUE and AbsTransf makes sure that D doesn't move. Absolutely transforms tugBoat with respect to D and then C with respect to tugBoat. Like TugTransf, but returns tugBoat to its original location. 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. 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. 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. May signal AssemblyHasNoChildren. Κ ˜Iheadšœ™Jšœ2™2Jšœ3™3Jšœu™uJ˜šΟk ˜ Jšœ˜Jšœ ˜ Jšœ ˜ —J˜Jšœ œ˜Jš˜J˜˜Jšœ œ˜'Jšœœ˜#Jšœ œ˜-Jšœ œ˜#Jšœ œ˜Jšœœ˜!J˜Jšœ’™’J˜—šΟn œœœœœœœ˜VJšœœœœœœœ8œœ™Ξ—šž œœœœœœœ˜VJšœœœœœœœ8œœ™Λ—š ž œœœ#œœ˜VJšœ.œ$™S—š žœœœ%œœ˜^Jšœ=™=—J˜Jšœž œ™'J˜Jšž œœœœœ œœ˜YJšžœœœœœ œœ˜TJšžœœœœœ œœ˜TJšžœœœœœ œœ˜Tš žœœœœœ œ˜TJ™V—J˜Jšœž œ™'J™Jšžœœœœ˜-Jšžœœœœ˜,Jšžœœœœ˜-Jšžœœœœ˜-Jšžœœœœ˜-procš žœœœœΟuœ ˜ELšœ[Ÿœ™]—šž œœœœ˜4L™Y—šž œœœœ˜1L™—J˜Jšœ#Οb œ™-™JšœŠž™Œ—Jšžœœœ%œ˜MJšž œœœ%œ˜JJšžœœ8˜FJšžœœ8˜EJšžœœœ%œ˜FJšžœœœ%œ˜FJšžœœœ%œ˜FJ˜Jšœ œ™&J˜šž œœ˜"J™X—šžœœ˜-J™ˆ—šžœœ3˜PJšœΰ™ΰ—šžœœ˜(Lšœ“ž™”—J™J˜Jš œ9™@™Jšœ/™/JšœN™NJšœš™šJšœœ™œJšœν™νJ™Α—Jšžœœœ˜5Jšžœœœ˜6Jšž œœ(œ˜=šžœœ(œ˜EJšœœ˜—šžœœ,œ˜NJšœ!™!—Jšž œœ,œ˜DJšžœœ,œ˜=J˜Jšœ˜—…— ŒΤ