Gimbal Lock

If there is something important you think is missing in the current version of ZGameEditor then you can post a feature request here!

Moderator: Moderators

Post Reply
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Gimbal Lock

Post 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
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

Welcome back Kjell :)
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post 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
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post 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.
kattle87
Posts: 402
Joined: Wed Sep 26, 2007 9:06 am
Location: Italy

Post by kattle87 »

actually, asin and acos can be easily calculeted with atan2:
http://en.wikipedia.org/wiki/Inverse_tr ... alculation
User avatar
turshija
Posts: 127
Joined: Sat Feb 17, 2007 9:26 am
Location: Novi Sad, Serbia
Contact:

Post 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 ? :)
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hejsan,

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

K
kattle87
Posts: 402
Joined: Wed Sep 26, 2007 9:06 am
Location: Italy

Post 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!
User avatar
turshija
Posts: 127
Joined: Sat Feb 17, 2007 9:26 am
Location: Novi Sad, Serbia
Contact:

Post 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)
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post 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
Post Reply