For the sake of brevity, its really hard to explain this without getting really nerdy so here’s a screenshot of the main code referencing different parts and using acos on a distance function between the two connection points to result in correct transformation and rotation.
Luckily, such calculations are no longer necessary in today’s age with rigging being much less tedious with premade nodes in Houdini and bones in other 3d software.
I plan on adding more to this using those nodes to add a complex setup in the back.