Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

t_quat::set: return a zero rotation instead of a zero quaternion #987

Closed
wants to merge 1 commit into from

Conversation

timoore
Copy link
Contributor

@timoore timoore commented Oct 4, 2023

It could be argued that the default constructor for quaternion should return a zero rotation i.e. {0, 0, 0, 1}, but I decided not to go there.

It could be argued that the default constructor for quaternion should
return a zero rotation i.e. {0, 0, 0, 1}, but I decided not to go
there.
@robertosfield
Copy link
Collaborator

Is this solving a particular problem? What happens with the unmodified code?

The default vsg::quat should probably match what glm does but just had a look at glm and left wondering WTF. So many headers for such basic functionality, not at all clear what is going on from a quick glance. Ahhh one of the main reasons I opted to implement maths classes part of the VSG, code base has got to be readable to be maintainable.

@robertosfield
Copy link
Collaborator

I been thinking about it, I'm leaning toward making zero rotation the default rather than 0,0,0,0 "invalid" rotation that we have right now. Still a bit torn though...

@kannode
Copy link
Contributor

kannode commented Oct 4, 2023 via email

@timoore
Copy link
Contributor Author

timoore commented Oct 4, 2023

Is this solving a particular problem? What happens with the unmodified code?

It's fixing the case of quat(0.0f, vec3(0.0f , 0.0f, 0.0f)) to return a 0 rotation. While this could be sensibly specified as undefined, Open Scene Graph set it to a zero rotation. Actually, Quat() in OSG results in (0, 0, 0, 1), so maybe that's the answer here too.

The default vsg::quat should probably match what glm does but just had a look at glm and left wondering WTF. So many headers for such basic functionality, not at all clear what is going on from a quick glance. Ahhh one of the main reasons I opted to implement maths classes part of the VSG, code base has got to be readable to be maintainable.

I don't care about glm 😄 , but OSG compatibility might be worth considering.

@timoore
Copy link
Contributor Author

timoore commented Oct 4, 2023

Do not be torn. Please initialize it as zero-rotation. I would have felt surprised it were not a unit-quaternion. [0, 0, 0, 1] - 0 rotation valid quaternion. [0, 0, 0, 0] - NOT a quaternion [nan, nan, nan, nan] - Could be a quaternion, but atleast things break immediately.

On Wed, Oct 4, 2023 at 1:23 PM Robert Osfield @.> wrote: I been thinking about it, I'm leaning toward making zero rotation the default rather than 0,0,0,0 "invalid" rotation that we have right now. Still a bit torn though... — Reply to this email directly, view it on GitHub <#987 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHWFHIO47DRM7VQ7GUYHNVDX5WLRJAVCNFSM6AAAAAA5SZOFDOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONBXGMZTKNBRHA . You are receiving this because you are subscribed to this thread.Message ID: @.>
-- S https://www.nodein.com/uresh K. Kannan, Ph.D., Chief Scientist, Nodein https://www.nodein.com

I don't agree that [0,0,0,0] is not a valid quaternion. It's certainly not a rotation, but it can meaningfully be used in quaternion multiplication.

There's a performance cost in having these primitive math types have non-trivial default constructors, but I suppose that we are over that.

@kannode
Copy link
Contributor

kannode commented Oct 4, 2023 via email

@robertosfield
Copy link
Collaborator

I have reflected on the issue and decided the best default is to go for the 0,0,0,1 zero rotation like the OSG. This is now checked into VSG master: 833f7db so I will close this PR as I think it's unnecessary. Thanks for the input @timoore and @kannode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants