I'm writing a Python script to move a bone of an armature to a desired Global 3D point. When armature has only one bone my function works well, but when I add not connected bones, there seems to be an error in the retrieved local coordinates.
target_vec = Vector((0.0405, -2.0305, 3.1172))
bone.location += (armature.matrix_world * bone.matrix).inverted() * target_vec
I want the center of the cone to touch one of the sides of the cube (see Figure).
The above function should send the bone to the fp point but it is sending it to the cp point instead.
https://drive.google.com/open?id=1FeIGb1C24Y44RJLfExFJB7EGhgSnzk1w
Any ideas of what am I missing?