I am trying to figure out the math behind orientating and translating a model so that a specified point on the model will connect with a specified point on another model. For example, given the following objects and respective "joints":

enter image description here

Where a joint is defined (relative to the model's untransformed position) as something like:

struct Joint
    Vector3 position;
    Vector3 normal;

I would like a function that can take a base model and a connecting model that modifies the "world" matrix of the connecting model. Something like:

public void ConnectModels(Matrix baseModelWorld, Joint baseJoint, Matrix connectingModelWorld, Joint connectingJoint)
    //Code to re-orient and re-position the connecting model's world matrix
    //Note: The joint position/orientation/normal need to be transformed by 
    //      the model's current world matrix

    //1. Transform the baseJoint/connectingJoint by the baseModelWorld/connectingModelWorld
    Vector3 baseJointPos = Vector3.Transform(baseJoint.position, baseModelMatrix);             
    Vector3 connJointPos = Vector3.Transform(connectingJoint.position, connectingModelMatrix);

    Vector3 baseJointNorm = Vector3.Transform(baseJoint.normal, baseModelMatrix);
    Vector3 connJointNorm = Vector3.Transform(connectingJoint.normal, connectingModelMatrix);

    //2. Orient the connecting model to match (opposite directions) base joint's normal

    //3. Translate the connecting model such that the connecting joint connects
    //        to the base joint.

    //4. ????

    //5. Profit
  1. But, I'm not very good at matrix math and I'm not sure what this actually translates to in code (or if this is correct/the best way).

  2. Also, I'm wondering if there is a better way to define a joint (i.e. just a Matrix, would that be possible?). Any help is appreciated!

  • \$\begingroup\$ Are you trying to build your model manually? Not through the help of modelling software such as Blender? \$\endgroup\$
    – user55564
    Dec 24 '14 at 7:09
  • \$\begingroup\$ Well yes and no, this is more of a mix and match kind of thing, I want to be able to connect whatever models I want dynamically to other models (where a model could be anything from a cube to an arm). That said, I'm sure the relevant math can be found somewhere in your link. I will check it out more in depth when I get a chance. \$\endgroup\$
    – Colton
    Dec 24 '14 at 8:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.