Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Studio Chat / [SOLVED] Quaternions / rotation problem using FixObjectToObject()

Author
Message
PSY
Developer
7
Years of Service
User Offline
Joined: 3rd Jul 2016
Location: Laniakea Supercluster
Posted: 27th Jan 2024 00:07 Edited at: 27th Jan 2024 00:08
Hey guys,

I'm having trouble understanding rotation after using FixObjectToObject().

In the following example, Earth rotates around the Sun.
I also attached the complete project with the media files as .zip.
There's no copyright issue with the .png files!



I used
to rotate Earth back to its default angle.
That worked, but after using the Quat command I'm unable to rotate Earth using

If I comment the Quat command,
works, but Earth angles are useless due to the Sun - Earth pivot.

Can anybody explain why the Euler rotation doesn't work anymore after setting the Quat rotation?
I can fix the problem by calculating the Earth orbit with sin and cos, but I want to understand what's going on.

Thanks!
PSY


PSY LABS Games
Coders don't die, they just gosub without return

Attachments

Login to view attachments

The author of this post has marked a post as an answer.

Go to answer

PSY
Developer
7
Years of Service
User Offline
Joined: 3rd Jul 2016
Location: Laniakea Supercluster
Posted: 27th Jan 2024 03:17 Edited at: 27th Jan 2024 03:21
This post has been marked by the post author as the answer.
I managed to get the code running by using the pivot method, but without using Quaternions.
I simply rotate Earth back around the Z axis by the same amount it was turned by using the pivot.
Then I rotate Earth around Y.
Just use the media files from the above post.


But I still wonder why I cant use Euler rotation after using SetObjectRotationQuat ( earth.ID, 0, 0, 0, 0 )...
I know I didn't increase the angle in the first code, but that doesn't matter at all. I simply can't rotate Euler after using Quat rotation.

PSY


PSY LABS Games
Coders don't die, they just gosub without return
Globbits
15
Years of Service
User Offline
Joined: 30th Jan 2009
Location: Cambridge
Posted: 22nd Feb 2024 11:16
I think the code you're using:



Should be



The default value of W is 1, not 0

I hope this helps.
PSY
Developer
7
Years of Service
User Offline
Joined: 3rd Jul 2016
Location: Laniakea Supercluster
Posted: 22nd Feb 2024 15:54
Nope, that makes it even worse

Thanks for trying though
Maybe I'll have a look at it another day. I solved the problem without having to use quaternions, so it's all good


PSY LABS Games
Coders don't die, they just gosub without return
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 22nd Feb 2024 19:22
I found that using RotateLocal would cause the object to "flip" when the Y rotation crossed the X axis. I solved this by saving the x/yz rotation values and using SetObjectRotation()

Login to post a reply

Server time is: 2024-04-13 03:27:14
Your offset time is: 2024-04-13 03:27:14