06-07-2012, 03:54 PM
3-D TRANSFORMATIONS
To perform the various 3-dimensional transformations such as translation, scaling, rotation.
Algorithm
Step 1: Input the figure.
Step 2: Display the menu as 1.Translation 2.Scaling 3.Rotation 4.Exit
Step 3: Get the choice from the user.
Step 4: If the choice is 1 a point or an object is translated from position P to position P' with the operation P'=T.P where tx,ty and tz specifying translation distances.
x'=x+ tx
y'=y+ ty
z'=z+ tz
Step 5: If the choice is 2 the scaling transformation of a position P can be written as P'=S.P where scaling parameters sx,sy and sz are assigned any positive values.
x'=x.sx
y'=y.sy
z'=z.sz
Step 6: If the choice is 3 get the rotation angle. Rotate the figure with respect to the axis of rotation.
Step 6a: About z axis rotation
x'=xcosӨ-ysinӨ
y'=xsinӨ+ycosӨ
z'=z
Rotation can be expressed as P'=Rz(Ө).P
Step 6b: About x axis rotation
y'=ycosӨ-zsinӨ
z'=ysinӨ+zcosӨ
x'=x
Rotation can be expressed as P'=Rx(Ө).P
Step 6c: About y axis rotation
z'=zcosӨ-xsinӨ
x'=zsinӨ+xcosӨ
y'=y
Rotation can be expressed as P'=Ry(Ө).P
Step 7: If choice is 4 exit the program.