-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
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
Added Euler angles rotation orders. #13538
Conversation
Rotations such as ZXZ are very commonly used for calculating part rotations in multi-axis CNC machine controls. I used the maths from the same matlab script that the Tait-Bryan angles were taken from, in the original code (link in comment in Quaternion.js.) |
@WestLangley what do you think? |
Were this to be integrated into core, for completeness, we would also have to add additional conversion methods for |
Hi @WestLangley
1. Yes, I have tested the ZXZ rotation and it works exactly as I’d expect it to. I haven’t tested all the other orders that I added, but I can definitely do that.
2. Yes, they are intrinsic rotations in their current form. Sometimes we do use extrinsic rotations to suit certain CNC machine controls that expect the tilted workplane to be calculated by a series of rotations around a fixed coordinate system. This is much less common.
3. I’m kind of surprised that no one has asked for this previously. It’s a very common requirement to calculate the rotations in this way in the world of machine control, and I’ve started to see a few machine control apps built with threejs. See ncviewer.com as an example. That doesn’t do multi axis plane rotations yet as far as I know, but I’d be surprised if they weren’t on the roadmap.
In my opinion, I feel that for completeness of the Euler library, they are just as valid as the Tait-Bryan rotations. Additionally, it was very confusing to me that I got no rotation at all when I entered “ZXZ” as the order, as the documentation didn’t specify that only Tait-Bryan angles were supported, so it was only when I went digging in the source, that I found out why. I think having them there would save others’ confusion.
4. Personally, for my current use case, I’d need all of the methods I’ve added. Each machine control we work with uses a particular order in that set. It varies a lot.
I could write the conversions to and from quat and matrix4 if necessary.
Thanks for considering this.
… On 9/03/2018, at 3:39 PM, WestLangley ***@***.***> wrote:
@thezwap
Did you test this code?
Are the "proper" Euler angles you added of the intrinsic type?
There has be no demand for these Euler types in three.js that I have been aware of. Would an examples/js/math/EulerUtils.js be acceptable, instead?
What would be the minimal set of methods that you would need to add to three.js to satisfy your use case?
Were this to be integrated into core, for completeness, we would also have to add additional conversion methods for Euler to-and-from Quaternion and Euler to-and-from Matrix4.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Please always test your PR before your file it.
The supported rotation orders are specified in http://imac.local/three.js/docs/#api/math/Euler. Unfortunately, it does not appear that
So, what are you doing as a workaround? |
|
When I replied previously and said the maths that I used provided intrinsic rotations, I based that on the fact that reversing the order of rotations, converts intrinsic rotations to extrinsic, e.g. XYZ = ZY'X'' and vise versa. I made the assumption that the same applied to proper Euler angles, but now I'm doubting myself. I'm currently looking for information on this topic, and struggling to find a definitive answer. I'll comment again when I've got to the bottom of it. |
So to clarify, all you need is for And you do not need And you do not need any of the other methods to support "proper" Euler angles? |
Correct (on all three points.) Here is my usage: The applyEuler function in the Vector3, calls Quaternion.setFromEuler() |
Also, I expect the arguments to the constructor have a different meaning in your case. In three.js, var euler = new THREE.Euler( a, b, c, order ); means rotate around the x-axis by var euler = new THREE.Euler( a, b, c, order ); means rotate around the 1st-axis by Correct? If so, we would need to use a different class to represent "proper" Euler angles. |
So, as I said previously, if were are to support the 6 additional Euler orders, we would have to support all possible orders in all relevant methods, and I think we would need a This is why something like THREE.MathUtils.setQuaternionFromProperEuler( q, a, b, c, order ); This method would implement your proposed code. Or, we could create a static method: Quaternion.setQuaternionFromProperEuler( q, a, b, c, order ); Edit: I think |
Oh, I see now. That sounds like it makes sense. That would work fine for me, and hopefully others. |
/ping @XanderLuciano Do you have any opinions on this proposed feature? |
Overall, I'm in favor of adding support. I like the recommendation of using
NCViewer, to a certain degree, can do some multi axis rotations: But I'm getting around the limitation by using multiple This is also something that Autodesk worked on relatively recently with our post processor (forum post about it), so to me it makes sense to add support for in Three.js as well. This way users won't have to figure out the math on their own if they want to work with Proper Euler angles. Overall, it doesn't look like this would add much code and it would be useful to anyone working with simulating and driving multi axis CNC machines, multi axis 3D printers, and possibly even robotic arms (though I only have limited experience there). |
Thanks, @XanderLuciano. Let's do this: create THREE.MathUtils.setQuaternionFromProperEuler( q, a, b, c, order ); There is no need to include a testbed, but it would be nice to see a link to one with a DAT.GUI supporting @thezwap Do you want to implement that? If not, I will be glad to. |
I'm keen to have a go and see how far I get. If I get completely stuck, I'll let you know and hand it over or ask for advice. Haven't used dat.gui before, but it looks fairly straightforward. |
@thezwap I needed this for something else, so here is a stub to get you started: https://jsfiddle.net/7aLfd0zd/ |
Thanks.
… On 13/03/2018, at 4:59 PM, WestLangley ***@***.***> wrote:
@thezwap I needed this for something else, so here is a stub to get you started: https://jsfiddle.net/7aLfd0zd/
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@thezwap As I expected, for performance reasons, the code should be written like this, instead: q.set( c2 * s13, s2 * c1_3, s2 * s1_3, c2 * c13 ); rather than setting each component /ping @mrdoob Ugh... |
Ok. Here's the link to the updated fiddle: https://jsfiddle.net/7aLfd0zd/17/ I've made the change to use q.set, as you suggested. What do you think about it setting all of the quat. parameters to 0 if an unspecified order is given. Is that a bad idea? |
examples/js/utils/MathUtils.js
Outdated
|
||
var s1 = sin(a / 2); | ||
var s2 = sin(b / 2); | ||
var s3 = sin(c / 2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Four of these are not used.
Yep. A quaternion that represents a rotation has unit length. The zero rotation is set by: You could leave the quaternion unchanged if the order is invalid. I do not think you need the intermediate variables |
Updated fiddle: https://jsfiddle.net/thezwap/7aLfd0zd/26/ |
Thanks. That's my first pull request. Good to see how the process works. |
Thanks! |
Only Tait-Bryan angles were supported previously.