How to determine direction of bone's movement?

Hi all,

I’m looking for the code to determine the direction of a bone’s movement. Specifically, I want to know if the bone is move on it’s local y-axis in a positive or negative direction. The bone has key frames set for it’s location.

I realize this is some where in vector or matrix math and I am very poor at math, so some explanations would be helpful.

Thanks,
Randy

well, if you have two keyframes, you have two positions- so you can subtract the first from the second and get the direction vector. It’s worth pointing out that even if the bone didn’t really move you might get a bit of ‘motion’ due to floating point errors, so you probably want to set some kind of minimum threshold to look for, and ignore any direction vector shorter than a given length

direction_vec = frame2_loc - frame1_loc
if direction_vec.length >= min_movememnt:
    # do stuff
1 Like

Yes, but where do I find the local location of the bone at?

Maybe this will hep explain what I am looking for:


I have a bone that travels in it’s +Y direction for 10 frames, moving in the world’s -Y direction. Then the bone turns to the left and moves in the world’s -X direction for 10 more frames along the bone’s local +Y axis. So how would I know that all that movement occurs along the bone’s local Y axis? And how to determine that the bone is moving in the bone’s local + or - Y axis?

Thanks for any help!
Randy