Archived

This topic is now archived and is closed to further replies.

nachilau

Scaling in a fix center

Recommended Posts

Hello, If I want to do scaling transformation in a fix center, what should I do. Right now, I first do a translation back to the origin, then scale it, and then translate it back to the before center. However, this method doesn''t work. Can anyone told me what is my problem? Current method matix: TBackMat = tran(center.x, center.y, center.z) TMat = tran(-center.x -center.y, -center.z) SMat = scal(0.1, 0.1, 0.1) then TMat*SMat*TBackMat is my final matrix. If this right. I want the center point of the object remain the same before and after the scaling transformation. Thanks! Nachi

Share this post


Link to post
Share on other sites
your idea is right

however after you have done the scale the amount you have to translate back is different, because you have scaled space. from the example you gave try:

TBackMat = tran(center.x*0.1, center.y*0.1, center.z*0.1)
TMat = tran(-center.x, -center.y, -center.z)
SMat = scal(0.1, 0.1, 0.1)

not sure thats right but hope it works



Share this post


Link to post
Share on other sites
However, it doesn''t works

Also, do you think I am worng in making the matrix in this order

TMat*SMat*TBackMat,

Ithink it should be

TBackMat*SMat*TMat,

sine first I move the object back to origin, then scale it and then translate back? Any idea?

Nachi

Share this post


Link to post
Share on other sites
You don't want to scale the translation as well, because then you'd be working in scaled space, when all you wanted to do was scale the object in the original space. You'd be scaling the system, not the object, and it wouldn't be consistant for everything else. In other words, you'd dehomogenize your object. That sounds bad, doesn't it?

[edited by - Zipster on November 1, 2002 7:05:40 PM]

Share this post


Link to post
Share on other sites
You had it right. Translate to origin, scale, translate back to position. You only have to make sure that your matrices are set up correctly.

Translation matrix looks like this:

[ 1 0 0 0 ]
[ 0 1 0 0 ]
[ 0 0 1 0 ]
[ x y z 1 ]

Scaling matrix looks like this:

[ x 0 0 0 ]
[ 0 y 0 0 ]
[ 0 0 z 0 ]
[ 0 0 0 1 ]

x y z being your translation values and scale values respectively.

Do your matrices look like that?

Share this post


Link to post
Share on other sites
I don''t think you translation martix is right, the general translation matrix should be like this

[ 1 0 0 x ]
[ 0 1 0 y ]
[ 0 0 1 z ]
[ 0 0 0 1 ]

I am sure my translation matrix is right since I build it by D3DX function in DirectX

However, no one can really give me the solution. Can anyone can really tell me how to solve my problem???



Share this post


Link to post
Share on other sites
They are both right. However, my system uses row matrices, where you would do Point * Transformation. You are using column matrices, where operations are Transformation * Point. Both are fine, just as long as the system is consistant.

quote:
However, no one can really give me the solution. Can anyone can really tell me how to solve my problem???

We have told you what you need to do, multiple times. What exact problems are you still having?

Share this post


Link to post
Share on other sites