Redefining the reference frame for the knee joint

Hi everyone,
I am new to AnyBody and my question might be a bit vague but your assistance in any kind is appreciated.

I am applying custom scaling where I am morphing the source femur to the match the target femur. With this, the knee joint center for the subject surely will deviate from the one defined for the source. As far as I know, I can choose landmarks (e.g., lateral and medial epicondyles) to define the center of the knee joint, and using these landmarks with the hip joint center to define the axes of the knee joint. Up to this point I do not know how can I overwrite (if i can call it this way) the source knee joint origin and axes to the subject-specific joint origin and axes?

AnyRefNode AnatomicalFrameBL = {
AnyVec3 O_us = 0.5*(.LatEpicondyleNodeBL.sRel_us + .MedEpicondyleNodeBL.sRel_us);
AnyVec3 Z_us = .MedEpicondyleNodeBL.sRel_us - .LatEpicondyleNodeBL.sRel_us;
AnyVec3 X_us = cross((.HipJointNodeBL.sRel_us - O_us),Z_us);
AnyVec3 Y_us = cross(Z_us,X_us);

AnyVec3 sRel_us = O_us;
AnyMat33 ARel_us = {X_us/vnorm(X_us),Y_us/vnorm(Y_us),Z_us/vnorm(Z_us)}';

Note that the landmarks are as below:
AnyRefNode LatEpicondyleNodeBL = {
#ifndef FEMUR_EPICONDYLES_3MATIC
AnyVec3 sRel_us = {-6.62741,-0.32052,-40.6968}*0.001;

#else
AnyVec3 sRel_us = {-5.1001, -6.5011, -43.3630}*0.001; //3-matic

#endif

DEF_REFNODE_CUSTOM_SCALING_1arg(sRel_us)
};
AnyRefNode MedEpicondyleNodeBL = {
#ifndef FEMUR_EPICONDYLES_3MATIC
//AnyVec3 sRel_us = {-13.3127,-0.102752,46.0024}*0.001;
AnyVec3 sRel_us = {-6.8826,-0.572676,46.7277}*0.001; //2nd take

#else
AnyVec3 sRel_us = {-7.6666, -1.9748, 47.6867}*0.001; //3-matic

#endif

DEF_REFNODE_CUSTOM_SCALING_1arg(sRel_us)
};
AnyRefNode HipJointNodeBL = {
AnyVec3 sRel_us = {-0.7323, 421.2953, -3.5333};
};

If there is a direct and easier way, please let me know.

Regards,
Omar

Hi Omar,

If you want to introduce custom scaling functions, I recommend you follow the Scaling tutorial. Briefly, the human body model is constructed in a way that if you implement the scaling function correctly, all the reference nodes (joint centers, muscle origin/insertion points, etc.) on the segment will be scaled using this function. So you don't need to redefine the joint centers again.

However, if you would like to define your own functional joint, you can use the body model statements for defining user defined joints:

#define BM_JOINT_TYPE_KNEE_RIGHT _JOINT_TYPE_USERDEFINED_

Please see this AMMR documentation page for reference.

I hope this helps!

Best regards,
Dave

Thank you so much Dave. Using the custom scaling function is quite straight forward and easier to implement. I appreciate your advice.

Best regards,
Omar