I’m working with the AnyForceSurfaceContact function for my shoulder model. I get the COP in the global reference, as described in the reference manual.
I now would like to express the COP in an “implant ref frame”, linked to the gh frame. My idea was to get the successive transform matrix and combine them to calculate the total transform matrix from gh to the global ref frame ; I could then express the COP in the implant ref frame [eq.1]: COP(gh) = inv(M(Implant-global)) * COP(global).
First question : is my method right ?!
If it is effectively right, my second question is the followimg : I get these successive frames :
- M1 : Implant relative to gh
- M2 :gh relative to scapula
- M3 :scapula relative to global.
But when I combine them (M = M1M2M3) and apply eq.1 I get something wrong since it show the COP very very far from the frame, wich is not the case visually in the model window. I supposed The scapula is defined relative to the global ref frame but I’m not absolutelly sure about that specific point.
Would you have any idea about my problems ?!
Thank you for your help !
isn’t your problem a simple change of coordinate systems?
In that case, if r_cop is the COP in global reference frame, r_gh the location of the GH joint (or your “implant ref frame”) in global ref frame and A_gh the orientation of the GH in global COS, I would say the transformation is given by
r_cop’ = A_gh * (r_cop - r_gh)
where r_cop’ is the position of the COP in the GH COS.
I hope this catches your problem.
Thank you for your return about my problems.
Before continuing, I’m not sure that I was clear enough in my precedent post : what I tried was to calculate the COP in the implant local ref frame in MATLAB and not directly in Anybobdy (why ? I don’t know…!).
Following your post, I so calculated the r_cop’ via Anybody. And great, it worked ! Here is my code, I think you would aggree with that (since working ) :
AnyFloat RotGhProth = .Seg.Scapula.gh.ghProth.Axes; // Rotation ghProth vs global
AnyFloat PosGhProth = .Seg.Scapula.gh.ghProth.r; // Position ghProth vs global
AnyVec3 COPlocalGhProth = (.Jnt.ProtheseContact.COP-PosGhProth) * RotGhProth ;
But… because I wanted to understand it well, I also tried to apply the same equation in Matlab. I think that I still applied the right equation but never right solution…
So I exported, from Anybody :
- COP = .Jnt.ProtheseContact.COP (=COP into global ref frame)
I don’t know how well you know Matlab , but here is my code ; can you see an error I would have and not found ?!
tr = COP*1000 - PosGhProth;
RotGhProth = reshape(RotGhProth', 3,3,size(RotGhProth,1));
for i = 1: size(RotGhProt,3)
COPlocalGhProth (i,:)= tr(i,:)*RotGhProt(:,:,i)
difficult to tell from the code you sent. I think the important part is how you import the data. In AnyBody, vectors are handled as row vectors. This is also the reason why the transformation is working with a matrix-vector product in the notation x * A.
Have you checked how the vectors look like after importing them into Matlab? Why do you have to transpose RotGhProth in the reshape command?
I thought I took into account the fact that I had row vectors after my import. For exemple it’s the reason why I made the “reshape” : I transformed the row vector into a 3*3 matrix to be abble to apply my matrix product. My error was effectively at this time, because I reshaped by column (in the time -space) and not byy row (in the x-y-z -space).
So, thank you again for helping me solving my problem !