1
$\begingroup$

According to the doc:

matrix

3x3 bone matrix

matrix_local

4x4 bone matrix relative to armature

I guess matrix_local is the full transform matrix that describes its location, rotation and scale in Pose Space, right? Then what's matrix? Why is it 3x3 instead of 4x4? If it's rotation mode is quaternion, then how 4 numbers fit in the 3-number row?

$\endgroup$

1 Answer 1

2
$\begingroup$

Yeah, the docs are useless. I'll try to answer based on my understanding from testing.

First, the properties on a bpy.types.Bone aren't affected by the Pose mode pose. Properties affected by the pose are on the bpy.types.PoseBone. So everything in bpy.types.Bone should depends only on the rest pose (the edit mode pose)

bone.matrix_local is the transform from bone space to armature space, calculated in the rest pose.

bone.matrix is the transform from bone space to its parent bone's space (or armature space if no parent) in the rest pose, but without the translation. The columns are bone.x_axis, bone.y_axis, bone.z_axis, which are the bone's x-axis, y-axis, and z-axis in its parent's coordinate space.

They seem to be related by

bone.matrix = (bone.parent.matrix_local.inverted() @ bone.matrix_local).to_3x3()

If it's rotation mode is quaternion, then how 4 numbers fit in the 3-number row?

That's not how it works. In both quaternion and euler mode, the rotation is used to calculate a 3x3 matrix that performs the rotation when applied to a vector. The numbers are never just inserted into a row of the matrix.

$\endgroup$
3
  • $\begingroup$ Oh I got it, it's just rotation. I assumed that the 3x3 matrix somehow stores translate+rotation+scale so I got confused. $\endgroup$ Commented Jul 8, 2021 at 14:03
  • $\begingroup$ But if bpy.types.Bone is bone in edit mode, then what's bpy.types.EditBone...? $\endgroup$ Commented Jul 8, 2021 at 14:05
  • 1
    $\begingroup$ EditBones only exist in Edit mode. AIUI when you leave edit mode, the bpy.type.Bones are all recalculated for the new rest pose. $\endgroup$
    – scurest
    Commented Jul 8, 2021 at 15:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .