Page 1 of 1

Gimbal Lock

Posted: Mon Jun 02, 2008 11:33 am
by Kjell
Hej,

For everyone that is not familiar with the problem that is Gimbal Lock.

You're going to run into this problem when for example wanting to make a 3D space exploration game like Elite or any other situation where you want to rotate over 3 axis. There are two good solutions for this. One is to support Quaternions , the other is Referential rotations ( Euler ).

Thanks ~
Kjell

Posted: Mon Jun 02, 2008 2:09 pm
by VilleK
Welcome back Kjell :)

Posted: Tue Jun 03, 2008 11:50 am
by Kjell
Hej Ville,

Tack sä mycket :) Good to be back :wink: Gimbal Lock unfortunately made me give up on implementing Camera roll when cornering ( preference went to pitch ), as you really need arcsin / arccos to calculate the values nicely. But no worries, it will still rock without it 8)

Regards,
K

Posted: Tue Jun 03, 2008 12:51 pm
by VilleK
Well implementing acos/asin is certainly easier for me than adding a new technique for rotations. The only reason I haven't added all the math-functions from the beginning is that I want to make some kind of function/preprocessor feature so that people that needs a specific function can use that, and it won't add to other peoples file sizes as it will only link in when used. But I think I need to push back those thoughts until I can spend more time on language research, and meanwhile just implement acos/asin as they are small functions anyway.

Posted: Tue Jun 03, 2008 6:07 pm
by kattle87
actually, asin and acos can be easily calculeted with atan2:
http://en.wikipedia.org/wiki/Inverse_tr ... alculation

Posted: Tue Jun 03, 2008 6:22 pm
by turshija
kattle87 wrote:actually, asin and acos can be easily calculeted with atan2:
http://en.wikipedia.org/wiki/Inverse_tr ... alculation
yes, but why not implementing simple asin and acos functions so we don't need to calculate it by ourselves every time ? :)

Posted: Sat Jun 14, 2008 11:53 pm
by Kjell
Hejsan,

And while we're at it .. atan() would be handy too :)

K

Posted: Sun Jun 15, 2008 9:13 am
by kattle87
again, you have atan2(), and that's enought for everyone :P

from wikipedia: "Thus implementations of atan(y) will probably choose to compute actually atan2(y,1)."
So, if you want normal atan (instead of atan2 which is best for me because can give you the angle in the [0, 2*PI] range), just use atan2(y,1)

bye!

Posted: Sun Jun 15, 2008 11:27 am
by turshija
i dont want to be rude :oops: , but:
turshija wrote:yes, but why not implementing simple asin and acos functions so we don't need to calculate it by ourselves every time ? :)
imagine someone starts using ZGE and he needs to google for manual asin and acos transformations only because the program doesn't support it ...
its much easier to write x = acos(angle); then going to wiki, finding the formula then transforming and writing all of that, right ? 8)

Posted: Sun Jun 15, 2008 1:41 pm
by Kjell
Hej Francesco,

You're right, I did try to use atan2 at first, but got some strange deviation initially .. must have been doning something wrong :oops: Working just fine now.

And turschija, acos and asin both got implemented in the recent 1.8.0 release :wink:

K