I did new track placing! Ewerything works just like in MSTS RE.
There are still small bugs, but it is infinitely better than the track placing in v501.
Elewated tracks:
http://i.imgur.com/ax9dVa7.png
That Genset Foamer, on 12 June 2015 - 03:53 PM, said:
I'm getting fairly decent results using this code. I'm certain all that's left to deal with is to force it to overcome rounding errors in the last couple stages.
[...]
Lemme know if this helps any!
Your code don't work for me. The problem is that it does a solution:
roll (-2PI, 2PI), pitch(-PI, PI), yaw(-2PI, 2PI)
but msts uses something like:
pitch(-2PI, 2PI), yaw(-PI, PI ), roll (-2PI, 2PI)
Finally I ended with solution based on transformating vector 0,0,10 by quaternion:
float qe[4];
float vect[3];
vect[0] = 0; vect[1] = 0; vect [2] = 10;
Vec3::transformQuat(vect, vect, q);
float pitch = asin(2*(q[0]*q[2] - q[1]*q[3]));
if(vect[2] < 0)
pitch = M_PI - pitch;
else if(vect[2] == 0 && vect[0] < 0)
pitch = M_PI/2;
else if(vect[2] == 0 && vect[0] > 0)
pitch = -M_PI/2;
qe[0] = tan((vect[1]/10.0));
qe[1] = pitch;
qe[2] = 0;
Only pitch is calculated using quat to roll,pitch,yaw equation, but in rare cases something is wrong so I'll probably rewrite it to a vector transformation too.