Hey Ben,

when moving a camera, you have to consider two things, 1) the cameraâs position in space 2) the cameraâs orientation in space. In oF, the cameraâs âorientationâ is also called its ârotationâ.

Positions are usually described as 3D vectors, whereas orientations/rotations are described in quaternions.

Every ofCamera is derived from ofNode, which should give you access to the position and the rotation as follows:

```
ofVec3f myCamGlobalPosition = myCam.getGlobalPosition();
ofQuaternion myCamRotation = myCam.getGlobalOrientation();
```

You can move the cameraâs position by tweening its position and simultaneously tweening its orientation over time, like so, assuming that your camera is called âmyCamâ:

```
// ofCamera myCam;
float tweenvalue = (ofGetElapsedTimeMillis() % 2000) /2000.f; // this will slowly change from 0.0f to 1.0f, resetting every 2 seconds
ofQuaternion startQuat;
ofQuaternion targetQuat;
ofVec3f startPos;
ofVec3f targetPos;
// we define the camer's start and end orientation here:
startQuat.makeRotate(0, 0, 1, 0); // zero rotation.
targetQuat.makeRotate(90, 0, 1, 0); // rotation 90 degrees around y-axis.
// we define the camer's start and end-position here:
startPos.set(0,0,0);
targetPos.set(0,0,600);
ofQuaternion tweenedCameraQuaternion; // this will be the camera's new rotation.
// calculate the interpolated orientation
tweenedCameraQuaternion.slerp(tweenvalue, startQuat, targetQuat);
ofVec3f lerpPos; //this will hold our tweened position.
// calculate the interpolated values.
lerpPos.x = ofLerp(tweenvalue, startPos.x, targetPos.x);
lerpPos.y = ofLerp(tweenvalue, startPos.y, targetPos.y);
lerpPos.z = ofLerp(tweenvalue, startPos.z, targetPos.z);
// alternative way to calculate interpolated values:
// lerpPos = startPos + ((targetPos-startPos) * tweenvalue);
// now update the camera with the calculated orientation and position.
myCam.setOrientation(tweenedCameraQuaternion);
myCam.setGlobalPosition(lerpPos);
```

Note that we use lerp to tween positions and *slerp* for rotations.

âLerpâ is short for linear interpolation, in which a value is scaled linearly, a bit like the in the classic formula y = k*x . If youâd plot the interpolation function as a graph, youâd get a straight line.

âSlerpâ on the other hand, is short for âspherical linear interpolationâ, meaning the quaternion is interpolated along a great circle so that the interpolation graph is following the shortest path between two points on a sphereâŚ

Cheers

#

Tim