// 2D TRANSFORMATIONS - REFLECTION AND INVERSION
//  To plot a triangle and perform the following transformations
// 1. Reflection w.r.t. Y axis
// 2. Reflection w.r.t X axis
// 3. Inversion (Reflection w.r.t. Origin)

clc // clear console
clf // clear the graphical window

a=gca() // assigning the access of data bounds to variable 'a'
a.data_bounds = [-1,-1;7,7]

X=[2,4,3,2]
Y=[2,2,4,2]
Z=[1,1,1,1]//DUMMY TO MAKE IT HOMOGENEOUS
D=[X;Y;Z]

S=[-1 0 0;0 1 0 ; 0 0 1] // Y- Reflection Transformation Matrix
plot2d(X,Y,5)
xtitle("REFLECTION","x","y")
Ds= S*D
Xs=Ds(1,:)
Ys=Ds(2,:)
plot2d(Xs,Ys,4)

S=[1 0 0;0 -1 0 ; 0 0 1] // X- Reflection Transformation Matrix
Ds= S*D
Xs=Ds(1,:)
Ys=Ds(2,:)
plot2d(Xs,Ys,3)

S=[-1 0 0;0 -1 0 ; 0 0 1] //Inversion Transformation Matrix
Ds= S*D
Xs=Ds(1,:)
Ys=Ds(2,:)
plot2d(Xs,Ys,2)

legend("OLD","Y Reflection","X Reflection","INVERSION")
xgrid()
