quaternion rotation values changing to inverse of what's needed when rotating beyond limits of current quaternion segment #108538

Closed
opened 2023-06-02 13:09:43 +02:00 by michael campbell · 12 comments

System Information
Operating system: Windows-10-10.0.19044-SP0 64 Bits
Graphics card: NVIDIA GeForce GTX 1070/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 526.98

Blender Version
Broken: version: 3.6.0 Alpha, branch: main, commit date: 2023-04-03 18:55, hash: 14b112ef825f
Worked: (newest version of Blender that worked as expected)

Short description of error
quaternion rotation values changing to inverse of what's needed when rotating beyond limits of current quaternion segment

Exact steps for others to reproduce the error
Difficult to explain, so here's a video showing the issue (attached). How do we embed video into the report now by the way?

**System Information** Operating system: Windows-10-10.0.19044-SP0 64 Bits Graphics card: NVIDIA GeForce GTX 1070/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 526.98 **Blender Version** Broken: version: 3.6.0 Alpha, branch: main, commit date: 2023-04-03 18:55, hash: `14b112ef825f` Worked: (newest version of Blender that worked as expected) **Short description of error** quaternion rotation values changing to inverse of what's needed when rotating beyond limits of current quaternion segment **Exact steps for others to reproduce the error** Difficult to explain, so here's a video showing the issue (attached). How do we embed video into the report now by the way?
michael campbell added the
Priority
Normal
Status
Needs Triage
Type
Report
labels 2023-06-02 13:09:44 +02:00
Iliya Katushenock added the
Interest
Animation & Rigging
label 2023-06-02 13:14:29 +02:00

I'll leave the final judgement to @dr.sybren but my understanding of quaternions is that it will always interpolate the shortest path between two keys.
Now why it works if you negate the values I am not sure. I thought the W channel needs to stay in a 0-1 range to be valid, but after a quick search it seems the lower bound is -1.

I'll leave the final judgement to @dr.sybren but my understanding of quaternions is that it will always interpolate the shortest path between two keys. Now why it works if you negate the values I am not sure. I thought the W channel needs to stay in a 0-1 range to be valid, but after a quick search it seems the lower bound is -1.

Yeah -1 to 1, then the vector and the angle flip between same and opposite direction to achieve a full rotation. Here's another example of the generated values not reflecting the user movement, and how to fix.

Yeah -1 to 1, then the vector and the angle flip between same and opposite direction to achieve a full rotation. Here's another example of the generated values not reflecting the user movement, and how to fix.
Contributor

Note that this is inconsistent with Eulers, which work as expected. If you spin the bone around a full revolution in Euler mode you go 0° -> 360°. The equivalent for quaternions would be to go 1 -> -1, but instead it goes 1 -> 1.

Note that this is inconsistent with Eulers, which work as expected. If you spin the bone around a full revolution in Euler mode you go 0° -> 360°. The equivalent for quaternions would be to go 1 -> -1, but instead it goes 1 -> 1.
Pratik Borhade added
Status
Needs Info from Developers
and removed
Status
Needs Triage
labels 2023-06-12 12:29:41 +02:00

Difficult to explain, so here's a video showing the issue (attached).

Please try to explain anyway. It's much faster to read a description than it is to watch a video. And those descriptions are indexed by search engines, so the report can actually be found by people having the same issue.

Also include a demo blend file that can be easily used to reproduce the issue, and clear steps to reproduce.

> Difficult to explain, so here's a video showing the issue (attached). Please try to explain anyway. It's much faster to read a description than it is to watch a video. And those descriptions are indexed by search engines, so the report can actually be found by people having the same issue. Also include a demo blend file that can be easily used to reproduce the issue, and clear steps to reproduce.

it will always interpolate the shortest path between two keys

You can use Alt+F to flip the quaternion, with that you have control over the direction of rotation.

Does this resolve this issue?

> it will always interpolate the shortest path between two keys You can use Alt+F to flip the quaternion, with that you have control over the direction of rotation. Does this resolve this issue?
Sybren A. Stüvel added
Status
Needs Information from User
and removed
Status
Needs Info from Developers
labels 2023-06-22 11:18:55 +02:00
Contributor

@dr.sybren Starting from the default cube, view it from the top in object mode and hit R to start rotating. Spin around one full rotation counter-clockwise. It goes from 0 degrees to 360 degrees. If you continue rotating it goes to 720, etc.

Now switch to quaternion rotation mode and do it again. It starts at w=1, but as you cross the 180 degree point, z=+1, it suddenly swaps to z=-1, so when you complete the rotation it comes back to w=1. It should be w=-1.

In Euler terms, this would be equivalent of it it suddenly switched from +180 degrees to -180 degrees as you crossed the 180 degree point so a full rotation would go from 0 back to 0.

The problem with this is it messes up animation. If the first keyframe is at 0 degrees, and you rotate by say 200 degrees forward and set a keyframe, you expect the animation to rotate 200 degrees forward, but it actually rotates 160 degrees backwards.

@dr.sybren Starting from the default cube, view it from the top in object mode and hit R to start rotating. Spin around one full rotation counter-clockwise. It goes from 0 degrees to 360 degrees. If you continue rotating it goes to 720, etc. Now switch to quaternion rotation mode and do it again. It starts at w=1, but as you cross the 180 degree point, z=+1, it suddenly swaps to z=-1, so when you complete the rotation it comes back to w=1. It should be w=-1. In Euler terms, this would be equivalent of it it suddenly switched from +180 degrees to -180 degrees as you crossed the 180 degree point so a full rotation would go from 0 back to 0. The problem with this is it messes up animation. If the first keyframe is at 0 degrees, and you rotate by say 200 degrees forward and set a keyframe, you expect the animation to rotate 200 degrees forward, but it actually rotates 160 degrees backwards.

I see your issue, but you didn't answer my question about Alt+F.

Now I see that this operator is only available when in pose mode, and not in object mode. I think the solution here would to simply make this operator available there too.

The problem with this is it messes up animation. If the first keyframe is at 0 degrees, and you rotate by say 200 degrees forward and set a keyframe, you expect the animation to rotate 200 degrees forward, but it actually rotates 160 degrees backwards.

This would depend on the internals of Blender's transform system. I don't know if it actually retains the direction in which the new orientation was reached.

I see your issue, but you didn't answer my question about Alt+F. Now I see that this operator is only available when in pose mode, and not in object mode. I think the solution here would to simply make this operator available there too. > The problem with this is it messes up animation. If the first keyframe is at 0 degrees, and you rotate by say 200 degrees forward and set a keyframe, you expect the animation to rotate 200 degrees forward, but it actually rotates 160 degrees backwards. This would depend on the internals of Blender's transform system. I don't know if it actually retains the direction in which the new orientation was reached.
Contributor

I don't what Flip Quats (Alt F) does. I tried it and it appears to do nothing. But I don't think any operator you run after the fact could fix this; the information about which way you actually rotated is gone after the rotation operation is done. And even if it did, it doesn't address the inconsistency with Euler mode.

I don't what Flip Quats (Alt F) does. I tried it and it appears to do nothing. But I don't think any operator you run after the fact could fix this; the information about which way you actually rotated is gone after the rotation operation is done. And even if it did, it doesn't address the inconsistency with Euler mode.

Hi @dr.sybren it seems there is already logic to handle the rotation going beyond 180 degrees on each axis, the issue is that that logic appears to be updating the values to be the inverse of what they should be.

Rather than users having to manually fix every single keyframe with a Alt + F, perhaps it would be better to just have the existing logic change to the correct values in the first place? They basically just need to be the inverse of what they currently are.

I have noticed by the way that the values that are chosen also seem to take into consideration the existing keyframes after the point on the timeline in which the new keyframe is being created. So I guess that will need to be factored in too.

Hi @dr.sybren it seems there is already logic to handle the rotation going beyond 180 degrees on each axis, the issue is that that logic appears to be updating the values to be the inverse of what they should be. Rather than users having to manually fix every single keyframe with a Alt + F, perhaps it would be better to just have the existing logic change to the correct values in the first place? They basically just need to be the inverse of what they currently are. I have noticed by the way that the values that are chosen also seem to take into consideration the existing keyframes after the point on the timeline in which the new keyframe is being created. So I guess that will need to be factored in too.

@3di if you can write down algorithmically how it would work, that would certainly help to see how much effort it would be to change the code & make things behave that way.

@3di if you can write down algorithmically how it would work, that would certainly help to see how much effort it would be to change the code & make things behave that way.
Member

quaternion rotation values changing to inverse of what's needed when rotating beyond limits of current quaternion segment

Guess this is expected behavior since quaternion chooses shortest path to interpolate between source and destination orientation.

> quaternion rotation values changing to inverse of what's needed when rotating beyond limits of current quaternion segment Guess this is expected behavior since quaternion chooses shortest path to interpolate between source and destination orientation.

This was discussed in yesterday's module meeting. Blender's current behaviour is not seen as a bug, and so I'll close this report.

I'd like to point at https://devtalk.blender.org/t/quaternion-interpolation/15883, where there's a much more in-depth discussion on quaternion interpolation in Blender.

This was discussed in [yesterday's module meeting](https://devtalk.blender.org/t/2024-01-04-animation-rigging-module-meeting/32785). Blender's current behaviour is not seen as a bug, and so I'll close this report. I'd like to point at https://devtalk.blender.org/t/quaternion-interpolation/15883, where there's a much more in-depth discussion on quaternion interpolation in Blender.
Blender Bot added
Status
Archived
and removed
Status
Needs Information from User
labels 2024-01-05 14:43:41 +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
5 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#108538
No description provided.