Camera rotation draws twoards Z (Animation script built from mathformula in Excel)

$\begingroup$

I have constructed a script in FME which calculates the position and rotation of the camera along a track "railroad track". I use math when I write my script so no standard functions. The software does automated interpolation between the cameras with the input (x,y,z) and Q(w,x,y,z).

But i get a strange result when i apply the script and the camera draws hard twoards Z when going into a curve. Anyone got the same result when working with camera animations? Video of my problem: Video of problem

The variables I have are Cameras (x,y,z) from the track, and the starting Quternion (w,x,y,z).The camera path simplyfied in a simple picture

My metod is:

1) Normalized V (Vx,Vy,Vz) is Camera 1 (x,y,z) to Camera 2 (x,y,z) Normalized P (Px,Py,Pz) is Camera 3 (x,y,z) to Camera 4 (x,y,z)

2) Cos Theta = V.P/|V|*|P|

3) Sin(Theta/2)

4) Normalize VxP

And then just apply it to standard form. Easy enough... The result is confirmed in Quternion calculation software for unit vectors.

// RotationAngle is in radians

x = RotationAxis.x * sin(RotationAngle / 2)

y = RotationAxis.y * sin(RotationAngle / 2)

z = RotationAxis.z * sin(RotationAngle / 2)

w = cos(RotationAngle / 2)

Then I just Multiply q2 * q1 == Qnew to cumulate the two rotations.

The new camera will be Camera 2(x,y,z) and Qnew(w,x,y,z). Any tips?

$\endgroup$ 2 Reset to default

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like