this uses extra trigonometry to do the math faster with less guesswork, compared to my previous approach. you can now click the yellow dot to flip the joint direction
like,,,