File: SVCoordSys.mesa
Last edited by Bier on May 5, 1987 1:17:08 am PDT
Author: Eric Bier in June, 1982
Contents: Allocation and access to a user-specified set of named coordinate systems
DIRECTORY
Rope, SV2d, SV3d, SVModelTypes, SVVector3d;
SVCoordSys: CEDAR DEFINITIONS =
BEGIN
CoordSystem: TYPE = SVModelTypes.CoordSystem;
CoordSysList: TYPE = SVModelTypes.CoordSysList;
Matrix4by4: TYPE = SV3d.Matrix4by4;
Point2d: TYPE = SV2d.Point2d;
Point3d: TYPE = SV3d.Point3d;
Vector3d: TYPE = SVVector3d.Vector3d;
Building the Tree
CreateRoot: PROC [name: Rope.ROPE] RETURNS [newCS: CoordSystem];
CreateCoordSysInTree: PROC [name: Rope.ROPE, mat: Matrix4by4, parent: CoordSystem, root: CoordSystem] RETURNS [newCS: CoordSystem];
NameAlreadyExists: SIGNAL;
CreateScalarsOnlyCoordSysInTree: PROC [name: Rope.ROPE, scalars: Vector3d, parent: CoordSystem, root: CoordSystem] RETURNS [newCS: CoordSystem];
CopyCoordSysFromAnyTree: PROC [source: CoordSystem, newName: Rope.ROPE, parent: CoordSystem, root: CoordSystem] RETURNS [newCS: CoordSystem];
Like CreateCoordSysInTree but uses the matrix from the old CoordSystem. If source is a scalars-only coordsys, then newCS will be as well.
PutAInTermsOfB: PROC [a: CoordSystem, b: CoordSystem] RETURNS [mat: Matrix4by4];
Finds the matrix and redefines CoordSystem a to be in terms of b from now on. A gets a new parent.
DeleteCoordSysAndChildren: PROC [cs: CoordSystem, root: CoordSystem];
FindCoordSysInTree: PROC [name: Rope.ROPE, root: CoordSystem] RETURNS [cs: CoordSystem];
CoordSysNotFound: SIGNAL;
CoordSysListEmpty: SIGNAL;
CoordSysNameIsPresent: PROC [name: Rope.ROPE, root: CoordSystem] RETURNS [BOOL];
MakeListFromTree: PROC [root: CoordSystem] RETURNS [csl: CoordSysList];
Produces a list of the CoordSystem's in subtree rooted at root. The list is in breadth-first order.
FindCoordSysInList: PROC [name: Rope.ROPE, csl: CoordSysList] RETURNS [cs: CoordSystem];
This procedure is on its way out. Use FindCoordSysInTree when possible.
Parent: PROC [cs: CoordSystem] RETURNS [parent: CoordSystem];
Name: PROC [cs: CoordSystem] RETURNS [name: Rope.ROPE];
SetName: PROC [cs: CoordSystem, name: Rope.ROPE];
GetSceneAssembly: PROC [world: CoordSystem] RETURNS [sa: CoordSystem];
Unique Names
BaseAndNumber: PROC [name: Rope.ROPE] RETURNS [base: Rope.ROPE, number: NAT];
UniqueNameWithSuffix: PROC [oldName: Rope.ROPE, suffix: Rope.ROPE, root: CoordSystem] RETURNS [unique: Rope.ROPE];
Takes a solidviews name, like "teapot.73". Adds the suffix to the basename and fixes the number to ensure uniqueness. If the suffix were "$$tool", then UniqueNameWithSuffix might return "teapot$$tool.89".
UniqueNameFrom: PROC [name: Rope.ROPE, root: CoordSystem] RETURNS [unique: Rope.ROPE];
NameWithSuffix: PROC [oldName: Rope.ROPE, suffix: Rope.ROPE, root: CoordSystem] RETURNS [probablyUnique: Rope.ROPE];
Takes a solidviews name, like "teapot.73". Fixes the number to ensure uniqueness. UniqueNameFrom might return "teapot.106".
Changing the Transformations
SetScalars: PROC [cs: CoordSystem, scalars: Vector3d];
cs must be scalarsOnly.
GetScalars: PROC [cs: CoordSystem] RETURNS [scalars: Vector3d];
cs must be scalarsOnly.
SetMat: PROC [cs: CoordSystem, mat: Matrix4by4];
changes the relationship of cs to its parent.
GetMat: PROC [cs: CoordSystem] RETURNS [mat: Matrix4by4];
IsScalarsOnly: PROC [cs: CoordSystem] RETURNS [BOOL];
reports the relationship of cs to its parent.
Transformation Queries
CameraToScreen: PROC [cameraPoint2d: Point2d, screenCoordSys: CoordSystem] RETURNS [screenPoint2d: Point2d];
ScreenToCamera: PROC [screenPoint2d: Point2d, screenCoordSys: CoordSystem] RETURNS [cameraPoint2d: Point2d];
FromCSToCS: PROC [pt: Point3d, currentCS: CoordSystem, newCS: CoordSystem] RETURNS [newPt: Point3d];
Takes ptcurrentCS and returns ptnewCS.
FromCSToCSMat: PROC [mat: Matrix4by4, currentCS: CoordSystem, newCS: CoordSystem] RETURNS [newMat: Matrix4by4];
Takes matcurrentCS and returns matnewCS.
WRTWorld: PROC [cs: CoordSystem] RETURNS [mat: Matrix4by4];
WRTCamera: PROC [cs: CoordSystem, cameraCS: CoordSystem] RETURNS [mat: Matrix4by4];
FindWorldInTermsOf: PROC [cs: CoordSystem] RETURNS [mat: Matrix4by4];
FindCameraInTermsOf: PROC [cs: CoordSystem, cameraCS: CoordSystem] RETURNS [mat: Matrix4by4];
FindAInTermsOfB: PROC [a: CoordSystem, b: CoordSystem] RETURNS [mat: Matrix4by4];
The above three procs return the relevant matrix with no side effects
FindTranslationOfAinTermsOfB: PROC [a: CoordSystem, b: CoordSystem] RETURNS [displacements: Vector3d];
END.