Incorrect rotation using driver or constraint #79118

Open
opened 2020-07-20 16:43:04 +02:00 by Roman · 12 comments

System Information
Operating system: Windows-7-6.1.7601-SP1 64 Bits
Graphics card: GeForce GTX 750 Ti/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 388.13

Blender Version
2.79, 2.80, 2.81, 2.82, 2.83

Short description of error

Bone "target" is animated on y-axis.
"Target" turned close to gimbal lock gives the wrong result for Transformation constraint, Copy Rotation constraint, Driver.
Using the driver, you can see how the radian (degrees) value jumps and does not match the value of the target object.
Only using the driver via copy data path creates the correct result.

rotation.blend

rotation_.mp4

**System Information** Operating system: Windows-7-6.1.7601-SP1 64 Bits Graphics card: GeForce GTX 750 Ti/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 388.13 **Blender Version** 2.79, 2.80, 2.81, 2.82, 2.83 **Short description of error** Bone "target" is animated on y-axis. "Target" turned close to gimbal lock gives the wrong result for Transformation constraint, Copy Rotation constraint, Driver. Using the driver, you can see how the radian (degrees) value jumps and does not match the value of the target object. Only using the driver via copy data path creates the correct result. [rotation.blend](https://archive.blender.org/developer/F8709086/rotation.blend) [rotation_.mp4](https://archive.blender.org/developer/F8716807/rotation_.mp4)
Author

Added subscriber: @roman-13

Added subscriber: @roman-13

#102679 was marked as duplicate of this issue

#102679 was marked as duplicate of this issue
Roman changed title from Wrong rotation Driver and Constraints to Incorrect rotation using driver or constraint 2020-07-21 10:57:54 +02:00

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'

Added subscriber: @dr.sybren

Added subscriber: @dr.sybren

@roman-13 In the future, please don't use GIF for videos. What is called a "gif" on modern websites is usually video file. H.264 in an MP4 container works fine for browsers, and is of higher image quality & smaller file size than GIF. It's nice to have a demo video that shows the issue, but modern video codecs are way better at that ;-)

@roman-13 In the future, please don't use GIF for videos. What is called a "gif" on modern websites is usually video file. H.264 in an MP4 container works fine for browsers, and is of higher image quality & smaller file size than GIF. It's nice to have a demo video that shows the issue, but modern video codecs are way better at that ;-)
Author

This comment was removed by @roman-13

*This comment was removed by @roman-13*
Author

@dr.sybren Ok. Is that better?
rotation_.mp4

@dr.sybren Ok. Is that better? [rotation_.mp4](https://archive.blender.org/developer/F8716807/rotation_.mp4)

@roman-13 much, thanks!

@roman-13 much, thanks!

I did some digging, and it seems to be caused by limitations of Euler angles.

Try this in Blender's Python Console:

>>> e26 = Euler((0.783653, 2.10281, 4.45932), 'YZX')
>>> e26.to_matrix().to_euler('YZX')

Euler((0.7836530208587646, 2.1028099060058594, -1.8238651752471924), 'YZX')

>>> e27 = Euler((0.783653, 2.18692, 4.45932), 'YZX')
>>> e27.to_matrix().to_euler('YZX')

Euler((-2.3579397201538086, -0.954672634601593, -1.3177274465560913), 'YZX')

Here e26 and e27 are the Euler angles of the target bone on frames 26 (before the jump in orientation) and 27 (after the jump in orientation) in radians. Converting them to a matrix and then back to Euler angles shows the issue: a small change in Y-angle results in a big change in the result. The same happens when converting from Eulers to quaternions and back.

The difference between the various approaches is that the "Copy Data Path" approach literally takes the Y euler rotation as-is. All the others first convert the rotation to a matrix, convert that matrix to whatever space is desired, convert it to Euler angles again, and and then take the value from that.

It could be argued that there could be some shortcuts in this process, to avoid unnecessary conversions. However, this would only apply to very specific cases (only local space, and no change in the order of angle evaluation), and could thus cause confusion in other areas. It could also break existing files, unless yet more options are added.

I did some digging, and it seems to be caused by limitations of Euler angles. Try this in Blender's Python Console: ``` >>> e26 = Euler((0.783653, 2.10281, 4.45932), 'YZX') >>> e26.to_matrix().to_euler('YZX') Euler((0.7836530208587646, 2.1028099060058594, -1.8238651752471924), 'YZX') >>> e27 = Euler((0.783653, 2.18692, 4.45932), 'YZX') >>> e27.to_matrix().to_euler('YZX') Euler((-2.3579397201538086, -0.954672634601593, -1.3177274465560913), 'YZX') ``` Here `e26` and `e27` are the Euler angles of the target bone on frames 26 (before the jump in orientation) and 27 (after the jump in orientation) in radians. Converting them to a matrix and then back to Euler angles shows the issue: a small change in Y-angle results in a big change in the result. The same happens when converting from Eulers to quaternions and back. The difference between the various approaches is that the "Copy Data Path" approach literally takes the Y euler rotation as-is. All the others first convert the rotation to a matrix, convert that matrix to whatever space is desired, convert it to Euler angles again, and and then take the value from that. It could be argued that there could be some shortcuts in this process, to avoid unnecessary conversions. However, this would only apply to very specific cases (only local space, and no change in the order of angle evaluation), and could thus cause confusion in other areas. It could also break existing files, unless yet more options are added.
Author

I found a discrepancy. I know the Y axis rotates in local coordinates, but I animated the X axis and for some reason the bone rotates with a constant in world space coordinate.

rotation_X.mp4
At a certain angle of rotation, Flip rotation also appears
flip_Z.mp4

I found a discrepancy. I know the Y axis rotates in local coordinates, but I animated the X axis and for some reason the bone rotates with a constant in world space coordinate. [rotation_X.mp4](https://archive.blender.org/developer/F8752375/rotation_X.mp4) At a certain angle of rotation, Flip rotation also appears [flip_Z.mp4](https://archive.blender.org/developer/F8752376/flip_Z.mp4)

That just looks like another gimbal lock to me.

I'm marking this as known issue as it seems to be a side-effect of how Blender handles space transformations, and not a bug in the implementation. As I said before, it might be possible to implement some shortcuts in the space conversion functions so that the conversion to matrix and back is avoided, but this requires very careful planning in order to not break existing files.

That just looks like another gimbal lock to me. I'm marking this as known issue as it seems to be a side-effect of how Blender handles space transformations, and not a bug in the implementation. As I said before, it might be possible to implement some shortcuts in the space conversion functions so that the conversion to matrix and back is avoided, but this requires very careful planning in order to not break existing files.

Added subscribers: @candreacchio, @ChrisLend

Added subscribers: @candreacchio, @ChrisLend
Philipp Oeser removed the
Interest
Animation & Rigging
label 2023-02-09 14:36:12 +01:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#79118
No description provided.