0
$\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?

  • 0
    Could you perhaps make this more mathematical and less code-like?2017-02-27
  • 0
    Consider posting this on stackoverflow instead, where users could look at your actual script and are more likely to be familiar with what you're doing. Alternatively, you could leave the post here, but as Brevan suggests, be very precise about what you are trying to calculate. As is, this is not very legible.2017-02-27

0 Answers 0