[38ba34]: / Body / AAUHuman / Arm / AddOnOutsideBlockForKinematics.any

Download this file

139 lines (97 with data), 4.7 kB

//This files add various various things which is need for the
//scapulo-thoracic gliding plane
//The scapula floats on an elipsoid, which is constructed using the standard
//geometric trick that if you define the two focus points a of the elipsoid, the line
//which starts in focus point1, goes to the surface of the elipsoid and return to 
//focus point2 will have a constant lenght.


//The content of this folder has to be scaled in a special way because the node in which this 
//the nodes in this folder is inserted in are rotated wrt. to thorax
//This means that when scaling, the nodes should scale together with thorax but since the reference system they are
//made in is rotated wrt. to thorax the vector has to be rotated back into the thorax ref frame, then scaled and rotated back again 

AnyFolder &ThoraxSegRef=ShoulderRef;

ThoraxSegRef ={
  
  AnyFunTransform3DLin Scale = {
    AnyFunTransform3DLin Transform_ijNode = {
      ScaleMat = ..ARel;
      Offset = ..sRelStd*..ARel;
    };
    PreTransforms = {
      &Transform_ijNode ,
      &.....BodyModel.Trunk.SegmentsThorax.ThoraxSeg.Scale
    };
    ScaleMat = .ARel';
    Offset = -.sRel;
  };
  
  AnyRefNode scj = { sRel = .Scale({0.020700, 0.009100, 0.023300}) * .Mirror;}; // simplified definition
  
  AnyMatrix  M = {{0,0,-1},{0,1,0},{1,0,0}};  //This matrix is used for to shift around the axis..

  AnyVar a_AI=0.25; //This is the original size of the elipsoid before any scaling
  AnyVar b_AI=0.16;
    
  //This node is used for controlling the size and orientation of the AI elipsoid
  //Remember the entire content of this folder is rotated wrt. to the thorax segment 
  //because it has been inserted in the ij and iji nodes which are both rotated
  //The ARel used below is the rotation of the node ShoulderRef.
  
  AnyVar a=0.25;
  AnyVar b=0.16;

  
  //input point 1
  AnyRefNode P1={
    sRel =.Scale({0.02,-0.13,0.163})*.Mirror; 
  };
  //Input point2
  AnyRefNode P2={
    sRel =.Scale({0.15,-0.13,0.11})*.Mirror; 
  };  
  
  //Standard origin of ellipsoid
  AnyVec3  ScapulaEllipsoidOriginStandard= {0.035220, -0.081006, 0.005573}; 
  
  AnyVec3  ScapulaEllipsoidOriginStandardScaled= Scale(ScapulaEllipsoidOriginStandard)*Mirror; 

  AnyVar R1=((ScapulaEllipsoidOriginStandardScaled[0]-P1.sRel[0])^2+(ScapulaEllipsoidOriginStandardScaled[1]-P1.sRel[1])^2+(ScapulaEllipsoidOriginStandardScaled[2]-P1.sRel[2])^2)^0.5;
  AnyVar R2=((ScapulaEllipsoidOriginStandardScaled[0]-P2.sRel[0])^2+(ScapulaEllipsoidOriginStandardScaled[1]-P2.sRel[1])^2+(ScapulaEllipsoidOriginStandardScaled[2]-P2.sRel[2])^2)^0.5;

  AnyVar RScaleFactor=(R1+R2)*0.5/RStandard;
  AnyVar R=RStandard*RScaleFactor;
  
  
  //Point for controlling the normal 
  AnyRefNode NormalControlPoint={
    sRel =.Scale({0.08,-0.06,0.155})*.Mirror; 
  };
  
  //Input point3
  AnyRefNode P3={
    sRel =.Scale({0.08,-0.0,0.14})*.Mirror; 
  };
  
  //Midpoint of the line p1,p2
  AnyRefNode P4={
    sRel=(.P1.sRel+.P2.sRel)/2;
    //Normal vector to plane p1,p2,p3
    ARel=RotMat(.P2.sRel,.P1.sRel,.NormalControlPoint.sRel); 
  };
  
  //Standard radius
  AnyVar RStandard=0.16;
  
  //Distance between p1 p2
  AnyVar w=((P1.sRel[0]-P2.sRel[0])^2+(P1.sRel[1]-P2.sRel[1])^2+(P1.sRel[2]-P2.sRel[2])^2)^0.5;
  
  //Distance from midpoint to center of circle
  AnyVar D=(R^2-(0.5*w)^2)^0.5;   
  
  AnyVec3 n=D*{.Sign*P4.ARel[0][2],.Sign*P4.ARel[1][2],.Sign*P4.ARel[2][2]};
  
  //Distance between p3 p4
  //AnyVar p3p4=((P3.sRel[0]-P4.sRel[0])^2+(P3.sRel[1]-P4.sRel[1])^2+(P3.sRel[2]-P4.sRel[2])^2)^0.5;
  
  
  
  
  //Corresponding to P5

  AnyRefNode ScapulaEllipsoidOrigin={
    sRel=.P4.sRel+.n + {0.0, -0.016, 0}; 
    AnyMat33 MAT=RotMat(.P2.sRel,.P1.sRel,.P3.sRel); 
    ARel=MAT;
    
    AnyVec3 P1LocalEllipCoo = (.P1.sRel-sRel)*ARel;
    AnyVec3 P2LocalEllipCoo = (.P3.sRel-sRel)*ARel;
    
    AnyVar X1 = P1LocalEllipCoo[0];
    AnyVar Y1 = P1LocalEllipCoo[1];
    AnyVar Z1 = P1LocalEllipCoo[2];
    
    AnyVar X2 = P2LocalEllipCoo[0];
    AnyVar Y2 = P2LocalEllipCoo[1];
    AnyVar Z2 = P2LocalEllipCoo[2];
    
    AnyVar A = ((Y2^2 - Y1^2*((X2^2 + Z2^2)/(X1^2 + Z1^2))) / (1 - ((X2^2 + Z2^2)/(X1^2 + Z1^2))))^0.5;
    AnyVar B = (- (X1^2 + Z1^2) / ((Y1^2 / A^2) - 1))^0.5;
    
    AnySurfEllipsoid  Elipse ={
      Radius={.B, .A, .B};
      //AnyDrawParamSurf drw={ Opacity = 0.5; };
    };
    
    AnyRefNode RotNode = 
    {
      ARel = RotMat( iffun(gtfun(...Sign,0), pi, 0.0), y)* RotMat( iffun(ltfun(...Sign,0), pi, 0.0), z);
    };
  };
  
  
  
}; //ThoraxRef