Page MenuHome

MatrixUtils LERP incorrect interpolation
Closed, ResolvedPublic

Description

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)

Revisions and Commits

Event Timeline

Brecht Van Lommel (brecht) lowered the priority of this task from 90 to 50.Apr 22 2017, 2:49 PM

@Campbell Barton (campbellbarton), 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 Van Lommel (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.