How can I mathematically connect 2 pieces together in c++?

Hi folks,

So I’m trying to implement a system where some buildable pieces have definitions containing sockets and knobs. The sockets contain information about what kinds of knobs can attach, the relative position to the blueprint root, and the relative rotation to the blueprint root (in Euler angles for readability).

If I wanted to attach one object to another with a specific socket and knob, how can I mathematically achieve that?

I have a transform that is the Actor’s position and rotation in the world. I need to rotate from there by the Euler angles to get the direction of attachment. The really tough part will be determining what rotation the object with the knob needs to be to properly align with the socket’s rotational information.

The knob, like a socket, has a local position relative to the blueprint’s root and Euler angles for the rotation.

Assuming I’ve determined a socket and knob, how can I calculate the rotation for the object with the knob to properly connect with a socket?

Thank you very much in advance for any help with this. It involves matrix inverses and transposes and all sorts of things I’m no longer familiar with.

-Matt

This is a visual example of what I’m trying to do.