Forums Anyscript.org  

Go Back   Forums Anyscript.org > General Forum > AnyBody Modeling System

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 11-02-2015, 11:07 AM
alfalfa alfalfa is offline
Junior Member
 
Join Date: Oct 2015
Posts: 3
Default transformation matrix

Im trying to translate and rotate a set of coordinates using a transformation matrix (calculated by another program) in AnyBody, but the resulting coordinates are different from what they should be.

This for eg. is the transformation matrix
a d g j
b e h k
c f i l
0 0 0 1

And this is the syntax that I used:
AnyFunTransform3DLin transformation=
{
ScaleMat = {{a,b,c},
{d,e,f},
{g,h,i}};
Offset = {j,k,l};
};

AnyRefNode transformedcoordinate = {
sRel = (.transformation({x,y,z}));
AnyDrawNode......
};

When I manually calculated the new coordinates using the same transformation matrix and plotted the new points, they were exactly where they should have been i.e. the transformation matrix is correct.

Can anyone tell me what Im doing wrong?

Thank you in advance!
Reply With Quote
  #2  
Old 11-02-2015, 12:40 PM
ananthgk1 ananthgk1 is offline
Member
 
Join Date: Aug 2015
Posts: 63
Default

Hi,

I think the issue might be that your ScaleMat is actually the transpose of what it is supposed to be. AnyMat33 arranges the three vectors row-wise, so for example your first row entry would be {a,d,j} and so on. Try re-arranging the terms and it should give you the same answer.

Regards
Ananth
Reply With Quote
  #3  
Old 11-02-2015, 01:17 PM
alfalfa alfalfa is offline
Junior Member
 
Join Date: Oct 2015
Posts: 3
Default

Hi Ananth,
Thank you for your reply!
I had tried that too (below), but it didn't work either.

AnyFunTransform3DLin transformation=
{
ScaleMat = {{a,d,g},
{b,e,h},
{c,f,i}};
Offset = {j,k,l};
};

Could it be something to do with the offset or the fourth row in the transformation matrix?
Reply With Quote
  #4  
Old 11-02-2015, 01:25 PM
ananthgk1 ananthgk1 is offline
Member
 
Join Date: Aug 2015
Posts: 63
Default

Hi,

Could you please share the exact numbers you are working with? i.e your matrix, test vector, expected transformed vector and actual transformed vector?
Reply With Quote
  #5  
Old 11-02-2015, 02:48 PM
pgalibarov's Avatar
pgalibarov pgalibarov is offline
Senior Member
 
Join Date: Oct 2010
Posts: 960
Default

Hi Irene,

According to the manual for AnyFunTransform3Lin:

"The linear scaling is defined by a 3 by 3 scaling matrix that is multiplied to the argument (3D geometrical vector) after adding a set of offset values."

So it is not "y=x+b*A" as you think, but "y=(x+b)*A". You can construct the transform to use the Offset=b*(A^-1).

Kind regards,
Pavel
Reply With Quote
  #6  
Old 11-02-2015, 02:54 PM
pgalibarov's Avatar
pgalibarov pgalibarov is offline
Senior Member
 
Join Date: Oct 2010
Posts: 960
Default

You could also avoid using the transformation and use the normal expression:

Code:
  AnyFloat k = {{1,0,0},{0,2,0},{0,0,3}};
  AnyFloat b = {0.1, 0.3, -0.2};
  
  AnyFloat test = {-1, 3, 4}*k+b;
Pavel
Reply With Quote
  #7  
Old 11-03-2015, 12:12 PM
alfalfa alfalfa is offline
Junior Member
 
Join Date: Oct 2015
Posts: 3
Default

Hello Pavel,

I used the AnyFloat commands and it worked perfectly.

Thank you!
Reply With Quote
Reply

Tags
coordinates, rotation, transformation matrix, translation

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 10:56 AM.