MatrixUtils LERP incorrect interpolation #51287

Closed
opened 2017-04-22 05:25:26 +02:00 by Dolphin Dream · 7 comments
Member

System Information
MacBook Pro
Processor 2.2 GHz Intel Core i7
Memory 16 GB 1333 MHz DDR3
Graphics AMD Radeon HD 6750M 1024 MB
Software OS X 10.12.3 - Sierra

Blender Version
2.78a (e8299c8)

Short description of error
When doing matrix interpolation with matrixutils lerp function for certain matrices the interpolation seems to give the wrong results.

Exact steps for others to reproduce the error
Type these in blender console or use within a script..

import mathutils
m1 = Quaternion((1,1,1,1)).to_matrix().to_4x4()
m2 = Matrix()
m1
m2
m2.lerp(m1,0)
m2.lerp(m1,1)
m1.lerp(m2,0)
m1.lerp(m2,1)

the terminal output:

>>> import mathutils
>>> m1 = Quaternion((1,1,1,1)).to_matrix().to_4x4()
>>> m2 = Matrix()
>>> m1

Matrix(((-3.0, 0.0, 4.0, 0.0),
        (4.0, -3.0, 0.0, 0.0),
        (0.0, 4.0, -3.0, 0.0),
        (0.0, 0.0, 0.0, 1.0)))

>>> m2

Matrix(((1.0, 0.0, 0.0, 0.0),
        (0.0, 1.0, 0.0, 0.0),
        (0.0, 0.0, 1.0, 0.0),
        (0.0, 0.0, 0.0, 1.0)))

>>> m2.lerp(m1,0)

Matrix(((1.0, 0.0, 0.0, 0.0),
        (0.0, 1.0, 0.0, 0.0),
        (0.0, 0.0, 1.0, 0.0),
        (0.0, 0.0, 0.0, 1.0)))

>>> m2.lerp(m1,1)

Matrix(((-2.1428568363189697, -1.428571343421936, 4.285714149475098, 0.0),
        (4.285714149475098, -2.1428568363189697, 1.428571343421936, 0.0),
        (1.428571343421936, 4.285714149475098, 2.142857074737549, 0.0),
        (0.0, 0.0, 0.0, 1.0)))

>>> m1.lerp(m2,0)

Matrix(((-2.1428568363189697, -1.428571343421936, 4.285714149475098, 0.0),
        (4.285714149475098, -2.1428568363189697, 1.428571343421936, 0.0),
        (1.428571343421936, 4.285714149475098, 2.142857074737549, 0.0),
        (0.0, 0.0, 0.0, 1.0)))

>>> m1.lerp(m2,1)

Matrix(((1.0, 0.0, 0.0, 0.0),
        (0.0, 1.0, 0.0, 0.0),
        (0.0, 0.0, 1.0, 0.0),
        (0.0, 0.0, 0.0, 1.0)))

I would expect that m2.lerp(m1, 1) should give m1 (which is is not the case)
I would expect that m1.lerp(m2, 0) should give m1 (which is is not the case)

matrixutils-lerp-bug.png

**System Information** MacBook Pro Processor 2.2 GHz Intel Core i7 Memory 16 GB 1333 MHz DDR3 Graphics AMD Radeon HD 6750M 1024 MB Software OS X 10.12.3 - Sierra **Blender Version** 2.78a (e8299c8) **Short description of error** When doing matrix interpolation with matrixutils lerp function for certain matrices the interpolation seems to give the wrong results. **Exact steps for others to reproduce the error** Type these in blender console or use within a script.. ``` import mathutils m1 = Quaternion((1,1,1,1)).to_matrix().to_4x4() m2 = Matrix() m1 m2 m2.lerp(m1,0) m2.lerp(m1,1) m1.lerp(m2,0) m1.lerp(m2,1) the terminal output: >>> import mathutils >>> m1 = Quaternion((1,1,1,1)).to_matrix().to_4x4() >>> m2 = Matrix() >>> m1 Matrix(((-3.0, 0.0, 4.0, 0.0), (4.0, -3.0, 0.0, 0.0), (0.0, 4.0, -3.0, 0.0), (0.0, 0.0, 0.0, 1.0))) >>> m2 Matrix(((1.0, 0.0, 0.0, 0.0), (0.0, 1.0, 0.0, 0.0), (0.0, 0.0, 1.0, 0.0), (0.0, 0.0, 0.0, 1.0))) >>> m2.lerp(m1,0) Matrix(((1.0, 0.0, 0.0, 0.0), (0.0, 1.0, 0.0, 0.0), (0.0, 0.0, 1.0, 0.0), (0.0, 0.0, 0.0, 1.0))) >>> m2.lerp(m1,1) Matrix(((-2.1428568363189697, -1.428571343421936, 4.285714149475098, 0.0), (4.285714149475098, -2.1428568363189697, 1.428571343421936, 0.0), (1.428571343421936, 4.285714149475098, 2.142857074737549, 0.0), (0.0, 0.0, 0.0, 1.0))) >>> m1.lerp(m2,0) Matrix(((-2.1428568363189697, -1.428571343421936, 4.285714149475098, 0.0), (4.285714149475098, -2.1428568363189697, 1.428571343421936, 0.0), (1.428571343421936, 4.285714149475098, 2.142857074737549, 0.0), (0.0, 0.0, 0.0, 1.0))) >>> m1.lerp(m2,1) Matrix(((1.0, 0.0, 0.0, 0.0), (0.0, 1.0, 0.0, 0.0), (0.0, 0.0, 1.0, 0.0), (0.0, 0.0, 0.0, 1.0))) ``` I would expect that m2.lerp(m1, 1) should give m1 (which is is not the case) I would expect that m1.lerp(m2, 0) should give m1 (which is is not the case) ![matrixutils-lerp-bug.png](https://archive.blender.org/developer/F566755/matrixutils-lerp-bug.png)
Author
Member

Changed status to: 'Open'

Changed status to: 'Open'
Author
Member

Added subscriber: @MariusGiurgi

Added subscriber: @MariusGiurgi

Added subscribers: @ideasman42, @brecht

Added subscribers: @ideasman42, @brecht

@ideasman42, the issue is that blend_m4_m4m4 assumes there is no shearing in the matrix, only scaling. Switching to interp_m4_m4m4 solves the problem but relies on Eigen, which means it can't work with MATH_STANDALONE.

@ideasman42, the issue is that `blend_m4_m4m4` assumes there is no shearing in the matrix, only scaling. Switching to `interp_m4_m4m4` solves the problem but relies on Eigen, which means it can't work with `MATH_STANDALONE`.

@brecht - if interp_m4_m4m4 resolves we better use it. MATH_STANDALONE allows mathutils to be build as a stand-alone C module, but shouldn't hold back fixes from going in.

Even for that use-case, the stand-alone module can use Eigen.

@brecht - if `interp_m4_m4m4` resolves we better use it. `MATH_STANDALONE` allows mathutils to be build as a stand-alone C module, but shouldn't hold back fixes from going in. Even for that use-case, the stand-alone module can use Eigen.

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'

This issue was referenced by 98df7d778f

This issue was referenced by 98df7d778f8b9318388bf24ab6be3b4930ef2f6f
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#51287
No description provided.