Skip to main content
added 223 characters in body
Source Link
batFINGER
  • 85.1k
  • 10
  • 114
  • 244

MatrixBlender 2.8+ Matrix multiplication

The question code method was writtenin place for <=2.79.9Blender <=2.79.9. Blender has since adjusted its mathutils module, replacing the asterisk * with the at symbol @, aka the PEP 465 binary operator, whenfor multiplying matrices andwith vectors.

>>> M = Matrix()
>>> v = Vector()
>>> M @ v
Vector((0.0, 0.0, 0.0))

>>> v @ v
0.0

>>> M @ M
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)))

Note using @ will throw the "same" error in"same type of error" in <= 2.79.9 and will need to be replacedReplace with * as in question code.

>>> M = Matrix()
>>> M @ M
Traceback (most recent call last):
  File "<blender_console>", line 1, in <module>
TypeError: unsupported operand type(s) for @: 'Matrix' and 'Matrix'

Matrix multiplication

The code was written for <=2.79.9. Blender has adjusted its mathutils module, replacing the asterisk * with the at symbol @, aka the PEP 465 binary operator, when multiplying matrices and vectors.

>>> M = Matrix()
>>> v = Vector()
>>> M @ v
Vector((0.0, 0.0, 0.0))

>>> v @ v
0.0

>>> M @ M
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)))

Note using @ will throw the "same" error in <= 2.79.9 and will need to be replaced with *

Blender 2.8+ Matrix multiplication

The question code method was in place for Blender <=2.79.9. Blender has since adjusted its mathutils module, replacing the asterisk * with the at symbol @, aka the PEP 465 binary operator, for multiplying matrices with vectors.

>>> M = Matrix()
>>> v = Vector()
>>> M @ v
Vector((0.0, 0.0, 0.0))

>>> v @ v
0.0

>>> M @ M
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)))

Note using @ will throw the "same type of error" in <= 2.79.9 Replace with * as in question code.

>>> M = Matrix()
>>> M @ M
Traceback (most recent call last):
  File "<blender_console>", line 1, in <module>
TypeError: unsupported operand type(s) for @: 'Matrix' and 'Matrix'
added 223 characters in body
Source Link
batFINGER
  • 85.1k
  • 10
  • 114
  • 244

Matrix multiplication

mathutils now usesThe code was written for <=2.79.9. Blender has adjusted its mathutils module, replacing the asterisk * with the at symbol @, aka the PEP 465 binary operator for, when multiplying matrices and vectors.

>>> M = Matrix()
>>> v = Vector()
>>> M @ v
Vector((0.0, 0.0, 0.0))

>>> v @ v
0.0

>>> M @ M
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)))

Note using @ will throw the "same" error in <= 2.79.9 and will need to be replaced with *

Matrix multiplication

mathutils now uses the PEP 465 binary operator for multiplying matrices

>>> M = Matrix()
>>> v = Vector()
>>> M @ v
Vector((0.0, 0.0, 0.0))

>>> v @ v
0.0

>>> M @ M
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)))

Matrix multiplication

The code was written for <=2.79.9. Blender has adjusted its mathutils module, replacing the asterisk * with the at symbol @, aka the PEP 465 binary operator, when multiplying matrices and vectors.

>>> M = Matrix()
>>> v = Vector()
>>> M @ v
Vector((0.0, 0.0, 0.0))

>>> v @ v
0.0

>>> M @ M
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)))

Note using @ will throw the "same" error in <= 2.79.9 and will need to be replaced with *

Source Link
batFINGER
  • 85.1k
  • 10
  • 114
  • 244

Matrix multiplication

mathutils now uses the PEP 465 binary operator for multiplying matrices

>>> M = Matrix()
>>> v = Vector()
>>> M @ v
Vector((0.0, 0.0, 0.0))

>>> v @ v
0.0

>>> M @ M
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)))