Animation3DImpl.mesa
Copyright © 1984 by Xerox Corporation. All rights reserved.
Last Edited by: Crow, March 28, 1986 4:19:36 pm PST
DIRECTORY
Vector3d   USING [Triple, Sub],
Matrix3d   USING [Transform, MakeRotate],
Animation3D  USING [];
Animation3DImpl: CEDAR PROGRAM
IMPORTS Vector3d, Matrix3d
EXPORTS Animation3D
~ BEGIN
Basic Types
Triple: TYPE ~ Vector3d.Triple;       -- RECORD [ x, y, z: REAL];
Procedures for Animation
MoveInOrbit: PUBLIC PROC[eyePt, lookingAt, axis: Triple,
         displayProc: PROC[eyePt, lookingAt: Triple],
          framesPerRev, numFrames: NAT, startAt: NAT ← 0 ] ~ {
theta: REAL ← 360. / framesPerRev;
currentEyePt: Triple;
FOR i: NAT IN [startAt .. startAt+numFrames) DO
currentEyePt ← Matrix3d.Transform[
eyePt,
Matrix3d.MakeRotate[
axis: Vector3d.Sub[axis, lookingAt],
theta: theta * i,
base: lookingAt
]
];
Call display procedure
displayProc[ [currentEyePt.x, currentEyePt.y, currentEyePt.z], lookingAt ];
ENDLOOP;
};
MoveOnLine: PUBLIC PROC[eyePt, lookingAt, toEyePt, toLookingAt: Triple,
         displayProc: PROC[eyePt, lookingAt: Triple],
         numFrames: NAT, startAt: NAT ← 0 ] ~ {
currentEyePt, currentLookingAt: Triple;
FOR i: NAT IN [startAt .. startAt+numFrames) DO
currentEyePt.x ← eyePt.x + (toEyePt.x - eyePt.x) * i / (numFrames-1);
currentEyePt.y ← eyePt.y + (toEyePt.y - eyePt.y) * i / (numFrames-1);
currentEyePt.z ← eyePt.z + (toEyePt.z - eyePt.z) * i / (numFrames-1);
currentLookingAt.x ← lookingAt.x + (toLookingAt.x - lookingAt.x) * i / (numFrames-1);
currentLookingAt.y ← lookingAt.y + (toLookingAt.y - lookingAt.y) * i / (numFrames-1);
currentLookingAt.z ← lookingAt.z + (toLookingAt.z - lookingAt.z) * i / (numFrames-1);
displayProc[currentEyePt, currentLookingAt];
ENDLOOP;
};
MoveOnCurve: PUBLIC PROC[eyePts, lookingAts: LIST OF Triple,
         displayProc: PROC[eyePt, lookingAt: Triple],
          numFrames: NAT, startAt: NAT ← 0 ] ~ {
currentEyePt, currentLookingAt: Triple ← [0., 0., 0.];
FOR i: NAT IN [startAt .. startAt+numFrames) DO
Evaluate curve  !!!!!!!
displayProc[currentEyePt, currentLookingAt];
ENDLOOP;
};
END.