First you need to get the world position of the bone's tip.
A naive way to do this is to start with a vector that is length, 0
using the bone's length, rotate it by the bone's worldRotationX
, then translate it by the bone's worldX, worldY
. The vector is now the world position of the bone's tip, but it will be wrong if the bone is skewed by nonuniform scale of a parent bone. The right way to do it is to use bone localToWorld
, passing in length, 0
.
Now you have a line segment representing the bone which is from the bone's worldX, worldY
to the world position of the bone's tip.
Next, you have a circle whose origin is the touch position. The radius of the circle is the touch distance.
Now all you need to do is line-circle intersection to see if the touch circle hits the bone line segment.