Matrix multiplications/ to_quat/ to_euler outputs incorrect rotation in some cases #83196

Closed
opened 2020-11-29 17:46:59 +01:00 by lucas veber · 8 comments

System Information
Operating system: Windows-10-10.0.19041-SP0 64 Bits
Graphics card: GeForce GTX 1080/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 446.14

Blender Version
Broken: version: 2.91.0, branch: master, commit date: 2020-11-25 08:34, hash: 0f45cab862
Worked: /

Short description of error
The matrix multiplication function is buggy, or the matrix > to_quat/to_euler conversion is buggy. This issue propagate in python addons that uses such functions, including the Fbx export where bones rotation are calculated in bone parent space:
https://developer.blender.org/T77811
It happens when a child bone has a nearly 180° angle or 0° with its parent bone, and possibly related to scale value being non equal to 1.

Exact steps for others to reproduce the error

  • Open this blend file:
    matrix_mul_error.blend

  • It contains two bones on the right: the longest one, named "2" is the child of "1". "2" is animated, making a simple rotation.

  • The bone on the left named "3" is used to testify the issue, as well as the mesh object on the left "Cube" to testify it doesn't happen with bones only

  • Click "Run Script". The script does the following > get the matrix in local space (parent space) of bone "2" > apply this matrix either by extracting the quaternion rotation from the matrix and set this rotation to bone "3", or by setting directly the matrix_local of "Cube"

  • Notice that rotations are incorrect, they jitter, while the rotation of bone "2" is pretty linear.

  • Now select bone "1" in Edit Mode, scale it bigger and rotate it upside down > No more jitters

**System Information** Operating system: Windows-10-10.0.19041-SP0 64 Bits Graphics card: GeForce GTX 1080/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 446.14 **Blender Version** Broken: version: 2.91.0, branch: master, commit date: 2020-11-25 08:34, hash: `0f45cab862` Worked: / **Short description of error** The matrix multiplication function is buggy, or the matrix > to_quat/to_euler conversion is buggy. This issue propagate in python addons that uses such functions, including the Fbx export where bones rotation are calculated in bone parent space: https://developer.blender.org/T77811 It happens when a child bone has a nearly 180° angle or 0° with its parent bone, and possibly related to scale value being non equal to 1. **Exact steps for others to reproduce the error** - Open this blend file: [matrix_mul_error.blend](https://archive.blender.org/developer/F9414027/matrix_mul_error.blend) - It contains two bones on the right: the longest one, named "2" is the child of "1". "2" is animated, making a simple rotation. - The bone on the left named "3" is used to testify the issue, as well as the mesh object on the left "Cube" to testify it doesn't happen with bones only - Click "Run Script". The script does the following > get the matrix in local space (parent space) of bone "2" > apply this matrix either by extracting the quaternion rotation from the matrix and set this rotation to bone "3", or by setting directly the matrix_local of "Cube" - Notice that rotations are incorrect, they jitter, while the rotation of bone "2" is pretty linear. - Now select bone "1" in Edit Mode, scale it bigger and rotate it upside down > No more jitters
Author

Added subscriber: @LucasVeber

Added subscriber: @LucasVeber

Added subscriber: @schampions

Added subscriber: @schampions

Perhaps there is a change that is not expected in Blenderbold text

Perhaps there is a change that is not expected in Blender**bold text**
lucas veber changed title from Matrix > to_quaternion outputs incorrect rotation in some cases to Matrix multiplications outputs incorrect rotation in some cases 2020-11-30 13:29:36 +01:00
lucas veber changed title from Matrix multiplications outputs incorrect rotation in some cases to Matrix multiplications/ to_quat/ to_euler outputs incorrect rotation in some cases 2020-11-30 14:29:36 +01:00

Added subscriber: @angavrilov

Added subscriber: @angavrilov

This looks like a numerical precision bug in matrix to quaternion conversion - if you convert matrix to euler directly, the problem seems to disappear.

This looks like a numerical precision bug in matrix to quaternion conversion - if you convert matrix to euler directly, the problem seems to disappear.
Author

Thanks for looking into this @angavrilov ! Well if this can be fixed as simply as that this is reassuring. Will test it thoroughly.

Thanks for looking into this @angavrilov ! Well if this can be fixed as simply as that this is reassuring. Will test it thoroughly.

This issue was referenced by 814b2787ca

This issue was referenced by 814b2787caddf5bd81477bd7b5dea8c45c402a72

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

Changed status from 'Needs Triage' to: 'Resolved'
Alexander Gavrilov self-assigned this 2020-11-30 19:47:48 +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
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#83196
No description provided.