Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@melund
Created March 5, 2012 08:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save melund/1977368 to your computer and use it in GitHub Desktop.
Save melund/1977368 to your computer and use it in GitHub Desktop.
Anatomical joint angles
// This file contains two template to measure anatomical joint angles
// and projected moments for the anybody modelling system.
//
// The CreateJointMeasures template creates a folder with measures of
// the anatomical joint angles. Angles are measured based on the
// Grood&Suntay convention also recommended by ISB.
//
// Inputs are AnyRefFrame derived classes which represent the antomical
// coordinate system for the segments. In the example below; all *StaticMarkerFrame
// are embedded cordinate systems between which the joint angles are measured.
//
// NOTE: The reference coordinate system needs to be defined in the model. Otherwise
// the code will not work. If this template should produce joint angles as
// recommended by ISB, then the coordinate systems (StaticMarkerFrame's) must be
// alligned as recommended by ISB.
//
// EXAMPLE:
// CreateJointMeasures Right (
// PELVIS_FRAME= BodyModelRef.Trunk.SegmentsLumbar.PelvisSeg.StaticMarkerFrame,
// THIGH_HIP_FRAME = BodyModelRef.Right.Leg.Seg.Thigh.HipStaticMarkerFrame,
// THIGH_KNEE_FRAME = BodyModelRef.Right.Leg.Seg.Thigh.KneeStaticMarkerFrame,
// SHANK_KNEE_FRAME = BodyModelRef.Right.Leg.Seg.Shank.KneeStaticMarkerFrame,
// SHANK_ANKLE_FRAME = BodyModelRef.Right.Leg.Seg.Shank.AnkleStaticMarkerFrame,
// FOOT_ANKLE_FRAME = BodyModelRef.Right.Leg.Seg.Foot.AnkleStaticMarkerFrame,
// ) = { Sign = 1;};
//
//
// The CreateJointAnglesAndMomentMeasures does the same CreateJointMeasures
// template. Additionally it also takes the three moment vectors as input, and
// calculate the moment vector projection onto the rotation axis. Note that the
// first and last rotation axis is not necessaryly perpendicular with Grood&Suntay
// convention so the projected moments may not make sense in physical way. However,
// they are often used in littereature so they are worth knowing.
//
// EXAMPLE:
// CreateJointAnglesAndMomentMeasures Left (
// THIGH_HIP_FRAME = BodyModelRef.Right.Leg.Seg.Thigh.HipStaticMarkerFrame,
// THIGH_KNEE_FRAME = BodyModelRef.Right.Leg.Seg.Thigh.KneeStaticMarkerFrame,
// SHANK_KNEE_FRAME = BodyModelRef.Right.Leg.Seg.Shank.KneeStaticMarkerFrame,
// SHANK_ANKLE_FRAME = BodyModelRef.Right.Leg.Seg.Shank.AnkleStaticMarkerFrame,
// FOOT_ANKLE_FRAME = BodyModelRef.Right.Leg.Seg.Foot.AnkleStaticMarkerFrame,
// HIPMOMENT = BodyModelRef.Left.Leg.MomentMeasure.HipNetMoment.M,
// KNEEMOMENT = BodyModelRef.Left.Leg.MomentMeasure.KneeNetMoment.M,
// ANKLEMOMENT = BodyModelRef.Left.Leg.MomentMeasure.AnklePlantarFlexionNetMoment.M
// ) = { Sign = -1;};
//
//
#class_template CreateJointMeasures (PELVIS_FRAME,THIGH_HIP_FRAME,THIGH_KNEE_FRAME,SHANK_KNEE_FRAME,SHANK_ANKLE_FRAME,FOOT_ANKLE_FRAME){
#var AnyInt Sign = 1;
AnyKinMeasureLinComb HipFlexion = {
AnyKinRotational HipMeasure ={
AnyRefFrame &PelvisRef = ...PELVIS_FRAME ;
AnyRefFrame &ThighRef = ...THIGH_HIP_FRAME ;
Type=RotAxesAngles;
Axis1 = z; Axis2 = x; Axis3 = y;
};
Coef = {{1,0,0}}*180/pi;
};
AnyKinMeasureLinComb HipAdduction = {
AnyKinRotational &HipJoint =.HipFlexion.HipMeasure;
Coef = .Sign *{{0,1,0}}*180/pi;
};
AnyKinMeasureLinComb HipInternalRotation ={
AnyKinRotational &HipJoint =.HipFlexion.HipMeasure;
Coef =.Sign *{{0,0,1}}*180/pi;
};
AnyKinMeasureLinComb KneeFlexion = {
AnyKinRotational KinRot ={
AnyRefFrame &ThighRef = ...THIGH_KNEE_FRAME;
AnyRefFrame &ShankRef = ...SHANK_KNEE_FRAME;
Type=RotAxesAngles;
Axis1 = z; Axis2 = x; Axis3 = y;
};
Coef =-1*{{1,0,0}}*180/pi;
};
AnyKinMeasureLinComb KneeAdduction = {
AnyKinRotational &KinRot = .KneeFlexion.KinRot;
Coef =.Sign *{{0,1,0}}*180/pi;
};
AnyKinMeasureLinComb KneeInternalRotation = {
AnyKinRotational &KinRot = .KneeFlexion.KinRot;
Coef =.Sign *{{0,0,1}}*180/pi;
};
AnyKinMeasureLinComb AnkleDorsiFlexion = {
AnyKinRotational KinRot ={
AnyRefFrame &ShankRef = ...SHANK_ANKLE_FRAME;
AnyRefFrame &FootRef = ...FOOT_ANKLE_FRAME;
Type=RotAxesAngles;
Axis1 = z; Axis2 = x; Axis3 = y;
};
Coef ={{1,0,0}}*180/pi;
};
AnyKinMeasureLinComb AnkleInversion ={
AnyKinRotational &KinRot =.AnkleDorsiFlexion.KinRot;
Coef =.Sign*{{0,1,0}}*180/pi;
};
AnyKinMeasureLinComb AnkleInternalRotation = {
AnyKinRotational &KinRot =.AnkleDorsiFlexion.KinRot;
Coef = .Sign*{{0,0,1}}*180/pi;
};
};
#class_template CreateJointAnglesAndMomentMeasures (PELVIS_FRAME,THIGH_HIP_FRAME,THIGH_KNEE_FRAME,SHANK_KNEE_FRAME,SHANK_ANKLE_FRAME,FOOT_ANKLE_FRAME, HIPMOMENT, KNEEMOMENT, ANKLEMOMENT ){
#var AnyInt Sign = 1;
AnyKinMeasureLinComb HipFlexion = {
AnyVar M_Projected = -..PELVIS_FRAME.Axes'[2]*..HIPMOMENT';
AnyKinRotational HipMeasure ={
AnyRefFrame &PelvisRef = ...PELVIS_FRAME ;
AnyRefFrame &ThighRef = ...THIGH_HIP_FRAME ;
Type=RotAxesAngles;
Axis1 = z; Axis2 = x; Axis3 = y;
};
Coef = {{1,0,0}}*180/pi;
};
AnyKinMeasureLinComb HipAdduction = {
AnyVar M_Projected = .Sign*cross(..PELVIS_FRAME.Axes'[2],..THIGH_HIP_FRAME.Axes'[1])*..HIPMOMENT';
AnyKinRotational &HipJoint =.HipFlexion.HipMeasure;
Coef =.Sign *{{0,1,0}}*180/pi;
};
AnyKinMeasureLinComb HipInternalRotation ={
AnyVar M_Projected = -1*.Sign*..THIGH_HIP_FRAME.Axes'[1]*..HIPMOMENT';
AnyKinRotational &HipJoint =.HipFlexion.HipMeasure;
Coef =.Sign *{{0,0,1}}*180/pi;
};
AnyKinMeasureLinComb KneeFlexion = {
AnyVar M_Projected = ..THIGH_KNEE_FRAME.Axes'[2]*..KNEEMOMENT';
AnyKinRotational KinRot ={
AnyRefFrame &ThighRef = ...THIGH_KNEE_FRAME;
AnyRefFrame &ShankRef = ...SHANK_KNEE_FRAME;
Type=RotAxesAngles;
Axis1 = z; Axis2 = x; Axis3 = y;
};
Coef =-1*{{1,0,0}}*180/pi;
};
AnyKinMeasureLinComb KneeAdduction = {
AnyVar M_Projected = .Sign*cross(..THIGH_KNEE_FRAME.Axes'[2], ..SHANK_KNEE_FRAME.Axes'[1])*..KNEEMOMENT';
AnyKinRotational &KinRot = .KneeFlexion.KinRot;
Coef =.Sign *{{0,1,0}}*180/pi;
};
AnyKinMeasureLinComb KneeInternalRotation = {
AnyVar M_Projected = -1*.Sign*..SHANK_KNEE_FRAME.Axes'[1]*..KNEEMOMENT';
AnyKinRotational &KinRot = .KneeFlexion.KinRot;
Coef =.Sign *{{0,0,1}}*180/pi;
};
AnyKinMeasureLinComb AnkleDorsiFlexion = {
AnyVar M_Projected = -1*..SHANK_ANKLE_FRAME.Axes'[2]*..ANKLEMOMENT';
AnyKinRotational KinRot ={
AnyRefFrame &ShankRef = ...SHANK_ANKLE_FRAME;
AnyRefFrame &FootRef = ...FOOT_ANKLE_FRAME;
Type=RotAxesAngles;
Axis1 = z; Axis2 = x; Axis3 = y;
};
Coef ={{1,0,0}}*180/pi;
};
AnyKinMeasureLinComb AnkleInversion ={
AnyVar M_Projected = .Sign*cross(..SHANK_ANKLE_FRAME.Axes'[2],..FOOT_ANKLE_FRAME.Axes'[1])*..ANKLEMOMENT';
AnyKinRotational &KinRot =.AnkleDorsiFlexion.KinRot;
Coef =.Sign*{{0,1,0}}*180/pi;
};
AnyKinMeasureLinComb AnkleInternalRotation = {
AnyVar M_Projected = -1*.Sign*..FOOT_ANKLE_FRAME.Axes'[1]*..ANKLEMOMENT';
AnyKinRotational &KinRot =.AnkleDorsiFlexion.KinRot;
Coef = .Sign*{{0,0,1}}*180/pi;
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment