<> <> <> DIRECTORY Vector3d USING [Triple, Sub], Matrix3d USING [Transform, MakeRotate], Animation3D USING []; Animation3DImpl: CEDAR PROGRAM IMPORTS Vector3d, Matrix3d EXPORTS Animation3D ~ BEGIN <> Triple: TYPE ~ Vector3d.Triple; -- RECORD [ x, y, z: REAL]; <> 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 ] ]; <> 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 <> displayProc[currentEyePt, currentLookingAt]; ENDLOOP; }; END.