Home Technical Talk

Quaternion versus Euler

Hey everyone, I believe this would be the right subforum for this question. I tried using search but the topics were really broad.

I use 3ds Max to animate and I have wondered what is best to use between Quaternion and Euler. Mainly I have been doing some character animations (biped) and wondered what would be best for them. Or what do the animators around here prefer? Or is it a situational thing?

Since Max defaults to Quaternion I use that, but don't tweak much in terms of curves or TCB (Which is bad because tweaking is a must at times)

Tips and/or suggestions are greatly appreciated.

Replies

  • sprunghunt
    Options
    Offline / Send Message
    sprunghunt polycounter
    it is a situational thing. Some engines do not accept one kind of rotation controller. Some engines don't care.

    You don't need to tweak curves. You can just put more keys in. But it's not bad to tweak curves. In some cases the exporter will not recognise your curves and just put in more keys to compensate.

    Some IK setups will work better with one type of rotation over the other but if you're using biped I'd use the default.
  • Eric Chadwick
  • Xer0
    Options
    Offline / Send Message
    @Sprunghunt Oh I didn't mean it was bad to tweak curves, I meant I thought it was bad I don't do it often. But thanks!

    @Eric Thanks for the links!
  • monster
    Options
    Offline / Send Message
    monster polycounter
    If you're talking about Biped, just leave it on quaternion. When my animation students show me that their Biped is vibrating when it shouldn't, I immediately know it's because they set the Euler option. The Euler option is really just an after thought.

    If you are using a custom rig, or the CAT plugin, you have access to the Euler curves. You may bump into gimbal lock occasionally. Sometimes the Euler Filter will fix it. But the control over individual curves can make animating faster.

    If you happen to animate vehicles I recommend changing the controllers to quaternion. The rotating tires will gimbal eventually, and it'll be a mess to untangle.
  • SpeCter
    Options
    Offline / Send Message
    SpeCter polycounter lvl 14
    the behaviour monster described is called Gimbal Lock.It doesn´t happen with Quaternions though.Quaternions are superior in almost any way(just harder to understand, which doesn´t concern us here)
  • Wrath
    Options
    Offline / Send Message
    Wrath polycounter lvl 18
    Most animators prefer working with Eueler because you can see and directly edit the f-curves. However, if a rig is careful with setting rotation order you can avoid most issues with gimbel in most circumstances. It's impossible to avoid in all situations, but you're really only going to run into it in the ball-and-socket joints, ie those with 3 axis of rotations...especially those with very broad range of motions.

    General rule of thumb for rotation order is 1st axis is 'twist', or along the length of the bone. 3rd axis is the main 'bend' angle. And the 2nd axis is the 'up' angle. For most limbs that's a pretty easy distinction. But for something like the upper-arm, it gets a bit trickier to identify the 'bend' axis. In those situations, I favor the the angle with the greater range as Z. Because of the way Eulers are resolved, the 1st and 3rd axis have a full range of -180 to 180, but the 2nd axis only has a range of -90 to 90. Beyond that, and you're going to get a flip on one of the other axis.

    Euler controllers also give you a easier value to connect to through parametric wiring or script controllers. If you're doing somethign like rigging some custom attributes on an IK foot controller then it's easier to wire directly to the Z rotation than jump through the extra hoops of working with quat or matrix3 values (though you can always get/put rotations as a EulerAngle in maxScript). There's also Expose Transform helpers that do a lot of the grunt work of converting matrix 3 values of an object into an array of values you can plug into a paramater or script. So, not really a deal breaker there.

    The main downside of Eulers (other than gimbel lock) is that an orientation can be reached in more than one way. So how you physically rotate an object for a keyframe can make a big difference to how orientation interpolates between keys. Fortunately, there is a Euler Filter tool in the graph editor to help sort things like that out.

    Quaternions are immune to gimbel lock because they're a vector (axis of rotation) and an angle (rotation amount). However, their interpolation between keyframes is controlled through Tension, Continuity, and Bias (TCB) settings, which many animators have difficulty dealing with. Most animators will avoid the issue alltogether by just adding extra keyframes rather than fiddle with TCB settings...but you'll still need to go in there an set something when you're dealing with holding a pose.

    One of the major drawbacks to aauaternions is also don't allow you to offset one axis of rotation in the timeline like you do with Eulers (something I do all the time when making cycles). Quats are a vector defining an axis and a float defining a rotation amount. So they're a more mathmatically precise way of describing the rotation of an object, but not in any way that normal animators think about rotation.

    I have worked with rigs that use a combination of controllers. In fact, I've generally found that the upper-arms are pretty much the main culprits for *really* needing TCB controllers. Everything else is either a simple hinge joint, only needing one axis of rotation, or doesn't require the same range of motion in all 3 axis and can generally be resolved by changing the rotation order on a Euler rotation. Even the upper-arms can work with a properly ordered Euler controller for 90% of the animations you might need.
  • Wrath
    Options
    Offline / Send Message
    Wrath polycounter lvl 18
    sprunghunt wrote: »
    it is a situational thing. Some engines do not accept one kind of rotation controller.

    Very unlikey any engine isn't using quat values for rotation. The export tool/process should be able to take an animation in the scene and convert the transform of each object on each frame and output to the data format needed (presumably a couple of point3s for position and scale, and a quat for rotation).

    Our current engine even does that in world space, so not only does it not care about what controllers your using, it doesn't even care about the heirarchy of nodes in the scene. It just exports everything in world space to an intermediary format which is then compiled into runtime data.
  • Xer0
    Options
    Offline / Send Message
    Cool. Thanks for the help guys!
  • Warheart
    Options
    Offline / Send Message
    Warheart polycounter lvl 17
    Yea, really good wisdom from Wrath there.

    I'd especially agree about the points made about gimbal lock being a relatively rare occurance provided the rotation orders of the rig controls are set up correctly. Shoulders are the most likely case as Wrath said but it also happens a lot in the case of prop/attachment objects. for example if you want a character to throw their weapon away and animate it spinning and falling out of their hand through space on multiple axes. Even this is not normally a problem in my experience though. I'm not as familiar with Max but on our rigs in Maya if you run into a situation where you need to spin an object further than Euler curves are happy to go then you can just convert the interpolation to quaternion on the fly even if you already have some keyframes. If that's not possible out-of-the-box in Max I suspect it would be possible to script.
  • rumblesushi
    Options
    Offline / Send Message
    Wrath wrote: »
    Very unlikey any engine isn't using quat values for rotation. The export tool/process should be able to take an animation in the scene and convert the transform of each object on each frame and output to the data format needed (presumably a couple of point3s for position and scale, and a quat for rotation).

    Our current engine even does that in world space, so not only does it not care about what controllers your using, it doesn't even care about the heirarchy of nodes in the scene. It just exports everything in world space to an intermediary format which is then compiled into runtime data.

    Is that purely down to interpolation? Obviously interpolating Quats is faster and easier than Matrices.

    However, I choose to use just matrices in my engine because it's significantly faster and also free from gimbal lock, as long as you update them incrementally rather than just construct from euler angles.

    With quaterions you have the added overhead of having to convert to matrix anyway for rendering purposes.
  • Mark Dygert
    Options
    Offline / Send Message
    monster wrote: »
    If you're talking about Biped, just leave it on quaternion. When my animation students show me that their Biped is vibrating when it shouldn't, I immediately know it's because they set the Euler option. The Euler option is really just an after thought.
    I agree, biped Euler is not much more than quaternion presented to look like Euler, under the hood its all quaternion, and as such you hit some snags that you wouldn't otherwise hit with standard Euler curves. It still doesn't fix the "not being able to slide one key (like rotation X) past another (rotation Y) without creating multiple keys.

    But for the few limitations it has, biped is an amazing rig that does a lot.
  • Mark Dygert
    Options
    Offline / Send Message
    Wrath wrote: »
    Most animators will avoid the issue alltogether by just adding extra keyframes rather than fiddle with TCB settings...but you'll still need to go in there an set something when you're dealing with holding a pose.
    TCB isn't that much different than dealing with the ease in/out options in the animation panel, which can be another quick way to keep from having to open the curve editor when working in Eular. There are scripts that help tweak the TCB values without having to lumber through the workbench which can seriously lag 3dsmax and make scrubbing the bar and playing back animation a nightmare in TCB or Euler.
    SpeCter wrote: »
    Quaternions are superior in almost any way(just harder to understand, which doesn´t concern us here)
    A lot of the time I'm animating max objects and biped which have two different curve editors and having them both out is cumbersome and even slower. So having a quick light interface for TCB is great. Of course it would be ideal if biped used the standard F-Curve editor with some slightly smarter filtering to get to the right curves but I they're all fixated on CAT right now... maybe some day.

    http://www.scriptspot.com/3ds-max/scripts/bipedkeyer-v1-4
    Great little tool, it would be hard to work quickly without it.
    BipedKeyer_scr1.gif
    Typically I use Tension 50 the most to kill any interpolation between keys.

    Next I use tension 40 to get a little follow through. Define your end pose set it to T40, copy the keys down the timeline a bit, set it to T50. You get some nice follow through that way, very simple, very quick.

    I make good use of the ease to and from presets also.

    Normally I don't need to see a visual representation of the curve to tweak the motion, I concentrate on the motion of the rig. Some animators worry about what people will say about their curves as if once the animation is out the public is going to pants them and laugh at their spiderman undies... Those guys normally end up obsessing about handles no one is ever going to see... if it looks good on the rig, it probably is. I don't mean to belittle the curve editors but for me I can get the same results often a bit quicker and not have to deal with the lag the editor introduces so until they clean that up its a bit more of a curse than a blessing.

    I also like to toggle on trajectories, its a bit more helpful to see the spacing of the keys and the actual arcs in 3D space It makes getting to know how to tweak the values a bit easier. But like the curve editor it can lag your scene out and create a cluttered visual mess if you select a bunch of joints so its good to have it set to a toggle.
  • Wrath
    Options
    Offline / Send Message
    Wrath polycounter lvl 18
    Warheart wrote: »
    Yea, really good wisdom from Wrath there.

    I'd especially agree about the points made about gimbal lock being a relatively rare occurance provided the rotation orders of the rig controls are set up correctly. Shoulders are the most likely case as Wrath said but it also happens a lot in the case of prop/attachment objects. for example if you want a character to throw their weapon away and animate it spinning and falling out of their hand through space on multiple axes. Even this is not normally a problem in my experience though. I'm not as familiar with Max but on our rigs in Maya if you run into a situation where you need to spin an object further than Euler curves are happy to go then you can just convert the interpolation to quaternion on the fly even if you already have some keyframes. If that's not possible out-of-the-box in Max I suspect it would be possible to script.

    For something like that you generally have more luxury with rigging extra dummy objects. Rotating an object on only one axis (ie, spinning) and linking that object to another dummy object that lets you keyframe the overall orientation, position, constraints, etc.

    You can freely convert between Euler and Quat in Max (pretty sure you'll lose any TCB or graph node handles you've set).
  • pen
    Options
    Offline / Send Message
    pen
    You can convert but you might not get what you expect all the time. Quats don't wind up for instance by default so converting an Euler that does a full 360 will result in an object that doesn't rotate at all.
  • r_fletch_r
    Options
    Offline / Send Message
    r_fletch_r polycounter lvl 9
    pen as in Paul Neale? (will be amazed if it is, but have to ask :))
  • pen
    Options
    Offline / Send Message
    pen
    That would be me. Have been meaning to start using this forum for some time now.
Sign In or Register to comment.