Jump to content

Euler/Quaternoin conversion (bug?)


hen
 Share

Recommended Posts

Uh oh, we have categorization police on the prowl.  :D  Are you sure this query belongs in the Bugs category, Dad?  It seems to me that this user is ASKING if this is a bug, and does not know if it is, yet.

But let's write 30 comments outlining the criteria for WHEN and WHERE to bring down the category-police baton on the heads of users, and then we can forget that the user's query still needs answering.  heh.  Forum-police training 101.  :D

I hereby vote (like anyone asked for votes)... that we NOT do categories, NOT do policing of mis-categorized posts, and not, in any way, be like stackOverflow. 

But, now that we have started this thread, and Dad72 has chosen to play police officer instead of answering the user's question, we might as well properly waste this thread.  The topic of this thread has now changed from Quaternion->Euler conversion, to category-police training.  How to properly do Gestapo ops on forums.  Alright!  heh.

Let's not go down the category police trail, eh?  Any chance?  I estimate that StackOverflow has over 30% wasted posts due to Gestapo patrols and user spankings.  Sad, imho.

But I must say, Dad72, that your traffic control directive was much more friendly than the rigid Gestapo power-junkies seen at the highly-unfriendly StackOverflow nightmare.  Thanks for that.  :) 

The smackOverflow[sic] site has seemingly forgotten that there is nothing more off-topic... than a post talking about whether the previous post was on/off topic.

A bit of a nasty post on my part, eh?  Sometimes things need hard-grinding and powerful points made.  It happens.  Let's avoid offended, and thick-skin debate this issue.  Move it to The Wingnut Chronicles, if wanted.

Link to comment
Share on other sites

Oh, Wingnut plays a lawyer.

If we think it is a bug, the bug is made for this category. I did not answer because I do not know the answer, but I know that sub-forums have been created for bugs.

This is not to make the police Wingnut. But thank you for your judgment. And you, you play the lawyer?

I really do not appreciate your sarcasm. Did I offend you at some point? or you just want to let off steam on somebody?

I would add that, you also, do not answer the question, and my answer was to help organizing the forum and you'll answer to what purpose, playing the lawyer, show your disagreement with the organization of the forum . For this, I do not think I can change anything. 

By cons I can help make the organization of the forum is taken into account and that anyone can do it without the police play as you say.

I think this organization is helpful and lets not mix things like bugs, projects and questions/reponses.

No "The Wingnut Chronicles" is good place. why the move, it is not the question, neither bugs nor a project. So it is in good location.

Have a nice day.


 

 

 

 

Link to comment
Share on other sites

I think Dad72 was right to write this. He was not policing, but trying to help with the future of the forum.

Yes, if it's a bug, it will be wonderful to have it in the bugs section for future reference.

AND, a simple search (the forum's search is SO much better suddenly!) will also show I already asked this question :) here - 

@Wingnut I think that the new structure will slowly be accepted by everyone. And I remember how dedicated you are answering people, especially if they get no replies. There's nothing wrong in giving this wonderful community a little "push" in the right direction :) I promise you it won't be stack overflow.

Link to comment
Share on other sites

Hey RaananW,

no worries.. next post goes to the right category :)

Since this is a bug, im having another question...

Ive noticed that most imported meshes do use quaternoin per default.
Is it maybe possible to change that back to use the euler?

 

Cheers

Hen

Link to comment
Share on other sites

Just now, Dad72 said:

Yes, 

mesh.rotationQuaternion = null;

 

Ive just found this in the documentation:  "You MUST use rotationQuaternion when creating physics objects. "

Wich means i must use quaternoins :(

Im lost.. i need the euler values on the level editor ui but even when using a custom conversion the matrix in babylon is set wrong....

Link to comment
Share on other sites

I always take directives like that (ie. no suggestion as to why) in documentation with a huge grain of salt. I guess maybe Euler angles shouldn't be used with physics because gimbal lock is almost inevitable with bodies that can rotate freely. As per the same doc ( https://github.com/BabylonJS/Babylon.js/wiki/How-to-handle-rotations-and-translations ) it looks like you can set the Quaternion directly (components as arguments to the constructor), so I wonder if you maybe work around the issue with an alternative conversion function?

Link to comment
Share on other sites

SO, what IS a "bug"?  Framework only?  Or, could it be a bug in a user's project?  Could it be a bug in a playground that is being used to test a section of a project?  Or just a playground bug, period?  How about a bug in a user's thinking?  Can "getting a playground to work"... be a project?  What about project questions?  Are projects announced in announcements?  Their beginnings?  Their progress reports? 

Categories sometimes work in forums where posts are 1-2 lines.  In that situation, MAYBE a category can be determined (by whom?). 

But this is the land of explaining and re-explaining... because there is a certain percentage of situations... where non-English speakers just don't understand the question being asked, or the situation at hand.  (like right now, likely)

If we're going to start spanking users with off-topic reprimands, this changes the entire attitude of this forum.  God/disciple crap is a disease that can ruin this place.  I've seen it happen.  All I ask is IF we are going to do "put this somewhere else" directives, then we SHOULD publicly define the "rules of the forum" very carefully and meticulously, so users can avoid being spanked.

I don't want a user to be excited that someone has replied to their topic, and opening the email shows that they have instead been told that their question was in the wrong place.  Because, if you want to discourage a BJS user... that's a perfect way to do it.

If it is the lawyer's job to make sure the rules and ramifications for breaking OTHER rules/guidelines... are clearly defined in public and in all languages, then yes, I will be glad to play the lawyer in our little pyramid-o-power fantasy.

We all know good and well what is happening here.  Before long, everyone and anyone is playing topic police, and we have a mess. In my opinion, this is a dangerous (and quite potentially unfriendly) shift of forum policy.  I'm going to try to head it off at the pass.  The "please make a playground" push/order has just BARELY had ANY acceptance.  This is not the time or place to try to impose new forum laws on folks who often speak little English... UNLESS we publish those forum rules/laws VERY PRECISELY in all languages.

Even then, let's just not go in that direction.  I believe folks are getting shoved-around plenty in their everyday lives... and they really don't desire getting shoved in the place where they come to escape that shoving.  The BJS forum is a place of webGL empowerment, not "how to properly use a forum"-dis-empowerment.  I would highly prefer to see NOTHING in this forum that discourages a user, or ruins their excitement... in ANY way.

What if Hen would have said "Please stay on the topic of Quaternion/Euler, Dad72"?  Counter-spanking!  Two police officers meeting head to head... each enforcing a different made-up rule/law.  Ridiculous.  A complete waste of time and emotions.  I stand my ground... let's not do policing and rule patrols.  Let's avoid it like the disease that it is.

@Hen... here's a non-answer comment:  I'm not experienced in porting models, but I THINK there is a checkbox in the Blender exporter panel that addresses something about exporting WITH/WITHOUT quaternion rotation.  ie.  Quaternion by default might be incorrect.  It might be based upon that checkbox... but... not sure.   And I don't think quaternion.toEuler() anomalies is a bug.  (see?  The categorization hell hath begun, eh?)  toEuler() just has serious near-the-poles "issues" caused by gimbal lock, a worldwide issue... not BJS only.  I could be wrong.

Link to comment
Share on other sites

5 hours ago, chg said:

I always take directives like that (ie. no suggestion as to why) in documentation with a huge grain of salt. I guess maybe Euler angles shouldn't be used with physics because gimbal lock is almost inevitable with bodies that can rotate freely. As per the same doc ( https://github.com/BabylonJS/Babylon.js/wiki/How-to-handle-rotations-and-translations ) it looks like you can set the Quaternion directly (components as arguments to the constructor), so I wonder if you maybe work around the issue with an alternative conversion function?

Setting the quaternoin is not the problem, but our app is has a rotation edit function wich displays euler values on the ui. 

It seems there is no workaround to convert the quaternoin back to the euler, wich is definitally a bug (same did work well with threejs before). 

Only workaround i see atm is to update a secondary property when the quaternoin was set from euler values.

 

 

Link to comment
Share on other sites

@hen It's quite difficult to convert Quaternion to Euler. I encounter this problem once, and, I meet a wall. :wacko:

@Wingnut, I understand your thinking or your fears, but I think we're all adults here. We can very well initially redirect to the corresponding categories so that it becomes a habit for everyone without the need to police or reprimand.
This can be achieved gently, here we are smart, we are not on a rigid psycho forum. But I think that a small organization the forum adds a bit of clarity. I understand what you think Wingnut, I also already seen this on some (even many) forum, but I think this can be avoided here. Redirect a member in the right categories, is not put spanked or reprimand, but just warn him that it exists and that it is more convenient for those who wish to correct the bug too.
I'm sure everything will pass well, without the need to play the police or the attorney.

Link to comment
Share on other sites

1 hour ago, Dad72 said:

@hen It's quite difficult to convert Quaternion to Euler. I encounter this problem once, and, I meet a wall. :wacko:

Yes that seems to be mission impossible...

It seems its the quaternoin itself wich is wrong... how could someone do games with this issue?

Link to comment
Share on other sites

My best suggestion for you would be - use quaternions.

I know - euler are easier to grasp - so nice, x, y ,z, yaw pitch and roll. Euler has a LOT of problems (Gimbal lock, anyone?). Quaternions are a weird beast. Why 4 variables? what's w?! ahhh!! 

But if you want to develop games, especially in the 3D world, learn how to use quternions. Or at least convert all of your euler angles to quaternions and start working with the rotate function. 

Link to comment
Share on other sites

Actually, if you read the math litterature on the Web about this problem, this isn't impossible at all but very complex as it depends upon the orientation of your system (left-handed for us) and about the euler angle order in which the rotation is done (Y, X then Z for us, think of your head natural movements to remember this order : left-right first -say no-, up-down then -say yes-, hears to shoulders in turn finally -say huuu-).

So some ways then :

- get your quaternion and reverse compute the angle knowing the two former constraints or find a good soul loving 3D trigonometry to do it for you (please, don't count on me this time ;))

- search the Web for the algo "quaternion to euler" (there are plenty) and adjust it according to the two former constraints

- search better the Web to find directly the alog "quaternion to euler in a left-handed sytem with rotations orderer Y, X then Z :P

 

I know my answer is not a real solution. Just a reminder to tell is not impossible, just complex.

Link to comment
Share on other sites

21 minutes ago, RaananW said:

My best suggestion for you would be - use quaternions.

I know - euler are easier to grasp - so nice, x, y ,z, yaw pitch and roll. Euler has a LOT of problems (Gimbal lock, anyone?). Quaternions are a weird beast. Why 4 variables? what's w?! ahhh!! 

But if you want to develop games, especially in the 3D world, learn how to use quternions. Or at least convert all of your euler angles to quaternions and start working with the rotate function. 

Yes i totally agree with you..

The problem was that the ui of the app must show the euler values/(Math.PI/180).
Im not developing a game from scratch, this is just moving an existing MMO/Virtual World from three.js to babylon.
Its almost fully ported... heres an (very) old preview when we did a soft launch in closed groups..



With the old three.js setup i was just converting directly from quaternoin to grab that values.
Since this isnt working i just added some setters and getters to the quaternoin that keep track of the euler input.

That works now... its all good :)

Link to comment
Share on other sites

@hen

Did you say that you're porting a game from ThreeJS to BJS ? (congratulions for this)

So I guess you have the threeJS code, don't you ? Maybe is there the part of code you need there ? 
Unless there's such a provided method in the ThreeJS API ? if yes, let us know, it would be a good basis to reimplement it in BJS.

Link to comment
Share on other sites

1 minute ago, jerome said:

@hen

Did you say that you're porting a game from ThreeJS to BJS ? (congratulions for this)

So I guess you have the threeJS code, don't you ? Maybe is there the part of code you need there ? 
Unless there's such a provided method in the ThreeJS API ? if yes, let us know, it would be a good basis to reimplement it in BJS.

Thats what i was trying as first. But the babylon issue seems to be related to the quaternoin itself.

Seems like three.js is solving it by additional order params.
Quat to euler is like euler.setFromQuaternoin(quaternoin, "XYZ").

But i think sorting the the euler order alone wont fix it. There is still problems with the returned values.

Link to comment
Share on other sites

14 minutes ago, Dad72 said:

I would be interested in your function. you can share it here?

Sure.. this is not really a function, its just an additional property:

Object.defineProperty(node, "rotation", {
        set: function(value) {
            if (this.node) {
                this.__rotation = [value[0], value[1], value[2]];
                this.node.rotationQuaternion = BABYLON.Quaternion.RotationYawPitchRoll(value[1]*(Math.PI/180), value[0]*(Math.PI/180), value[2]*(Math.PI/180))
            }
        },
        get: function() {
            if (this.node && this.__rotation) {
                return this.__rotation
            } else {
                return [0,0,0]
            }
        },
        configurable: true,
        enumerable: true
    });

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...