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
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];
A set of routines which call IncTransf:
Translate: PROC [c: Slice, scene: Scene, vec: Vector3d, d: CoordSystem ← NIL, dFixed: BOOLFALSE];
Rotate: PROC [c: Slice, scene: Scene, axis: [1..3], degrees: REAL, d: CoordSystem ← NIL, dFixed: BOOLFALSE];
PlaneOriginRotate: PROC [c: CoordSystem, d: CoordSystem, degrees: REAL, plane: NAT];
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:
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];
Places C so that the rotation from C to D remains as it is, but the translation is set to vD.
NormalizeRot: PROC [c: Slice, scene: Scene, d: CoordSystem];
Leave translation between C and D as is. The axes of C become parallel to the axes of D.
Normalize: PROC [c: Slice, scene: Scene, d: CoordSystem];
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.
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];
Routines for updating cached matrices:
DirtyAssembly: PROC [a: Slice];
This assembly has moved. Mark its coordinate system and those of its children as dirty.
TidyUpCoordSysTree: PROC [root: CoordSystem];
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];
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];
May signal AssemblyHasNoChildren.
Scale: PROC [c: Slice, scene: Scene, sx, sy, sz: REAL, d: CoordSystem ← NIL];
END.