2
$\begingroup$

I'm trying to export bone coordinates using ob.find_armature().data.bones.

I made a test file that has two connected bones, and set these position values manually in the UI.

Bone 1 Coordinates

  • Head: (1, 1, 1)
  • Tail: (2, 2, 2)

Bone 2 Coordinates (connected to Bone 1)

  • Head: (2, 2, 2)
  • Tail: (3, 3, 3)

So I go to access the bone data in python, and here's what I get.

Bone 1 Coordinates

  • Head: (1, 1, 1)
  • Tail: (2, 2, 2)
  • I guess these are absolute world coordinates.

Bone 2 Coordinates (connected to Bone 1)

  • Head: (0, 0, 0) These must be relative to the last bone's tail.
  • Tail: (-0.00000, 1.732051, 0.000000) What are these?

Proof and test Blend file: https://app.box.com/s/olb6hzi3p0z4ejqbtyfk

https://i.stack.imgur.com/xM4Tc.png

$\endgroup$
1
  • 1
    $\begingroup$ Figured out that head_local and tail_local will give me the coordinates I'm looking for, but I wish someone could explain what those other coordinates are. $\endgroup$
    – 371273
    Nov 7, 2014 at 6:52

1 Answer 1

2
$\begingroup$

API docs:

head - Location of head end of the bone relative to its parent

head_local - Location of head end of the bone relative to armature

tail - Location of tail end of the bone

tail_local - Location of tail end of the bone relative to armature

Since Bone 1 has no parent, the vector between object origin and bone head is used.

Bone 2's head it at Bone 1's tail (Connected is ticked), thus Bone 2's head is at (0, 0, 0) because there is no distance between both.

Bone 2's tail is at (0, 1.732, 0) because it's given relative to its parent bone. Bone 1 and 2 face the very same direction, all it takes is the length of the bone to define its endpoint (Bone direction is on the Y-axis in Blender). Tail minus head is

(3, 3, 3) - (2, 2, 2) = (1, 1, 1)

and the length

sqrt(12 + 12 + 12) = ~1.732
$\endgroup$
2
  • $\begingroup$ How would I go about calculating an absolute location based on that tail vector? $\endgroup$
    – 371273
    Nov 16, 2014 at 22:51
  • $\begingroup$ Should be ob.matrix_world * bone.tail_local. Not sure how to do that for bone.tail, likely involved some fancy matrix math. $\endgroup$
    – CodeManX
    Nov 17, 2014 at 0:25

You must log in to answer this question.

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