Forums Anyscript.org transformation matrix
 Register FAQ Calendar Search Today's Posts Mark Forums Read

 Notices Meet us !

#1
11-02-2015, 11:07 AM
 alfalfa Junior Member Join Date: Oct 2015 Posts: 3
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?

#2
11-02-2015, 12:40 PM
 ananthgk1 Member Join Date: Aug 2015 Posts: 63

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
#3
11-02-2015, 01:17 PM
 alfalfa Junior Member Join Date: Oct 2015 Posts: 3

Hi Ananth,
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?
#4
11-02-2015, 01:25 PM
 ananthgk1 Member Join Date: Aug 2015 Posts: 63

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?
#5
11-02-2015, 02:48 PM
 pgalibarov Senior Member Join Date: Oct 2010 Posts: 960

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
#6
11-02-2015, 02:54 PM
 pgalibarov Senior Member Join Date: Oct 2010 Posts: 960

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
#7
11-03-2015, 12:12 PM
 alfalfa Junior Member Join Date: Oct 2015 Posts: 3

Hello Pavel,

I used the AnyFloat commands and it worked perfectly.

Thank you!

 Tags coordinates, rotation, transformation matrix, translation

 Thread Tools Display Modes Linear Mode

 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 Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Professional Forum     AnyBody Managed Model Repository     Gallery of user models and videos     AnyGait     AnyBody Exporter for SOLIDWORKS     Debug model General Forum     AnyBody Modeling System     Wish list for AMS and AMMR     Announcements Self-Supported Forum     AnyBody Model Repository     Debug model Archive     AnyScript Message Archive

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