Page MenuHome

Drivers: support decomposing rotation into bending followed by twist.
ClosedPublic

Authored by Alexander Gavrilov (angavrilov) on Sep 1 2019, 4:29 PM.

Details

Summary

In order to correctly drive corrective shape keys from a freely
rotating joint it is very often found necessary to decompose the
rotation into separate bending and twisting motions. This type
of decomposition cannot be reproduced by any Euler order or
a single quaternion.

This is done by using a helper bone with a Damped Track constraint
aimed at the tail of the control to pick up the bending part, and
its helper child with Copy Transforms to separate the twist.

Requiring two additional bones to drive a shape key or a correction
bone seems inconvenient, so this implements the necessary math as new
options in the recently introduced Rotation Mode dropdown of the
Transform Channel driver variable type. The data is also accessible
as a Transformation constraint input.

The output is in the form of Quaternion-derived 'pseudo-angles',
which for Bend + Y Twist would represent the following:

  • W: true bend angle, independent of bend direction.
  • X, Z: pseudo-angles representing the proportion of bending around X/Z.
  • Y: true twist angle.

Diff Detail

Repository
rB Blender
Branch
bend-twist-angles (branched from master)
Build Status
Buildable 4719
Build 4719: arc lint + arc unit

Event Timeline

Test file - the big arrows now use the new option, while the smaller euler ones have to rely on Damped Track.

This is how the pseudo-angles fade out as the bend rotation axis moves away from their axis:

I call them 'pseudo' because unlike eulers they don't really represent any geometrically specific kind of angle, except if rotating purely around X or Z.

Functionality seems fine.

We have a similar (same?) swing and twist decomposition in the IK solver for rotation limits.

Maybe "swing" is a better name than "bend", which has some other meanings in Blender? Also would not use "+" in the name. So maybe Swing and X Twist?

source/blender/blenkernel/intern/fcurve.c
1806–1834

I guess we can move this code into a BLI_math function?

Maybe "swing" is a better name than "bend", which has some other meanings in Blender? Also would not use "+" in the name. So maybe Swing and X Twist?

I for some reason personally associate the Damped Track transformation with a stiff rubber rod bending, and organic joints (as opposed to mechanical Track To).

source/blender/blenkernel/intern/fcurve.c
1806–1834

I suppose the splitting quaternion into two bit could be next to rotation_between_vecs_to_quat and others. The quaternion_to_angles is somewhat more ad-hoc than mathematical - with all the converting quaternion components into weird 'weighted angles' business.

Renamed to Swing and rewrote the math to be more efficient based on ideas from IK solver code.

This revision is now accepted and ready to land.Sep 3 2019, 6:25 PM