Link to home
Start Free TrialLog in
Avatar of ARSSES
ARSSES

asked on

MAKING TRANSFORMATIONS USING BORLAND C++

can anyone help me, please
how can I make some transformations "like translation,
scaling, rotation, ...." using the Borland C++ 3.1
Graphics Package?

thanks
ARSSES.  
ASKER CERTIFIED SOLUTION
Avatar of ankuratvb
ankuratvb
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Avik Dasgupta
Avik Dasgupta
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi,

All these transformations i.e. translation,scaling and rotation have standard matrices that
are used.
Just do a Google for :2D transformations "computer graphics"

U'll get plenty of links and there are a number of standard matrices that are used by dif.
authors.

Some represent the matrices as row matrices,some as column matrices.

In my program ,i have used the fol. matrix format
x' and y' are the co-ordinates after tranformations
x and y are the co-ordinates before tranformations.

Matrices of 3 columns(why the extra 1?u could have asked) have been used for 2D to make the co-ordinates homogeneous i.e. all the operations can be represented as matrix multiplications


[x' y' 1]=[x y 1][1 0 0
                         0 1 0
                        tx ty 1]

For translation where tx and ty are the translation displacements respectively.

[x' y' 1]=[x y 1][sx  0 0
                         0  sy 0
                         0   0  1]

For scaling where sx and sy are the scale ratios in x and y respectively.

[x' y' 1]=[x y 1][cos a  sin a  0
                         -sin a cos a  0
                           0        0      1]

For rotation where a is the angle in degrees and this is rotation anti-clockwise.
For clockwise,replace a by -a

So,if u have a number of points say 3 points,
store them in matrix as:
[x1 y1 1
 x2 y2 1
 x3 y3 1]
and multiply this matrix with the appropriate transformation matrix to get the new co-ordinates.


HTH
Avatar of ARSSES
ARSSES

ASKER

HI,

I WNTA TO SAY THANKS FOR ANKURATUB & AVIK77
 FOR HELPING ME "MANY THANKS".

ARSSES
Glad to be of help.