hen Posted January 16, 2016 Share Posted January 16, 2016 Im having a problem converting euler > quaternoin > euler. The x input euler returns as z. I made a playground to show it http://www.babylonjs-playground.com/#20LBVQ#8 Quote Link to comment Share on other sites More sharing options...
Dad72 Posted January 16, 2016 Share Posted January 16, 2016 Hi, There is a sub-forum to post the bugs to keep good organization of this one and ease the task to those who correct them if necessary. Thank you Quote Link to comment Share on other sites More sharing options...
Wingnut Posted January 16, 2016 Share Posted January 16, 2016 Uh oh, we have categorization police on the prowl. 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. 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. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted January 16, 2016 Share Posted January 16, 2016 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. RaananW 1 Quote Link to comment Share on other sites More sharing options...
RaananW Posted January 16, 2016 Share Posted January 16, 2016 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. Dad72 1 Quote Link to comment Share on other sites More sharing options...
hen Posted January 16, 2016 Author Share Posted January 16, 2016 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 Quote Link to comment Share on other sites More sharing options...
Dad72 Posted January 17, 2016 Share Posted January 17, 2016 Yes, mesh.rotationQuaternion = null; Quote Link to comment Share on other sites More sharing options...
hen Posted January 17, 2016 Author Share Posted January 17, 2016 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.... Quote Link to comment Share on other sites More sharing options...
chg Posted January 17, 2016 Share Posted January 17, 2016 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? Quote Link to comment Share on other sites More sharing options...
Wingnut Posted January 17, 2016 Share Posted January 17, 2016 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. Quote Link to comment Share on other sites More sharing options...
hen Posted January 17, 2016 Author Share Posted January 17, 2016 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. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted January 17, 2016 Share Posted January 17, 2016 @hen It's quite difficult to convert Quaternion to Euler. I encounter this problem once, and, I meet a wall. @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. Quote Link to comment Share on other sites More sharing options...
hen Posted January 17, 2016 Author Share Posted January 17, 2016 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. Yes that seems to be mission impossible... It seems its the quaternoin itself wich is wrong... how could someone do games with this issue? Quote Link to comment Share on other sites More sharing options...
RaananW Posted January 17, 2016 Share Posted January 17, 2016 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. Quote Link to comment Share on other sites More sharing options...
jerome Posted January 17, 2016 Share Posted January 17, 2016 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 I know my answer is not a real solution. Just a reminder to tell is not impossible, just complex. Quote Link to comment Share on other sites More sharing options...
hen Posted January 17, 2016 Author Share Posted January 17, 2016 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 RaananW 1 Quote Link to comment Share on other sites More sharing options...
jerome Posted January 17, 2016 Share Posted January 17, 2016 @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. Quote Link to comment Share on other sites More sharing options...
hen Posted January 17, 2016 Author Share Posted January 17, 2016 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. Quote Link to comment Share on other sites More sharing options...
jerome Posted January 17, 2016 Share Posted January 17, 2016 mmmhh... this looks very like the same BJS functions : https://github.com/mrdoob/three.js/blob/master/src/math/Euler.js#L231 Quote Link to comment Share on other sites More sharing options...
hen Posted January 17, 2016 Author Share Posted January 17, 2016 2 minutes ago, jerome said: mmmhh... this looks very like the same BJS functions : https://github.com/mrdoob/three.js/blob/master/src/math/Euler.js#L231 Yes.. i believe the problem is somehow with the matrix. .. oh i have a idea.. hold on... Quote Link to comment Share on other sites More sharing options...
hen Posted January 17, 2016 Author Share Posted January 17, 2016 This is so weird.. sorry i have really no idea whats wrong. For my personal use i found that solution described above. But im wondering if this issue might affect other things in babylon as well. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted January 17, 2016 Share Posted January 17, 2016 2 hours ago, hen said: i just added some setters and getters to the quaternoin that keep track of the euler input. I would be interested in your function. you can share it here? Quote Link to comment Share on other sites More sharing options...
hen Posted January 17, 2016 Author Share Posted January 17, 2016 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 }); Dad72 1 Quote Link to comment Share on other sites More sharing options...
Dad72 Posted January 17, 2016 Share Posted January 17, 2016 Thank you. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 18, 2016 Share Posted January 18, 2016 on the same topic, I'm open to any suggestion to improve the euler<->quaternion tools we have:) Dad72 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.