You are on page 1of 20

Grafic asistat de calculator 2014

Implemetarea in Maple a transformrilor geometrice n plan (exprimate matriceal n


coordonate omogene)

> translatie2D:=proc(tx,ty)
> local a;
> a:=array(1..3,1..3,[[1,0,tx],[0,1,ty],[0,0,1]]);
> RETURN(evalm(a))
> end proc;
translatie2D := proc(tx, ty)
local a;
a := array( 1 .. 3, 1 .. 3, [ [ 1, 0, tx ], [ 0, 1, ty ], [ 0, 0, 1 ] ] ) ; RETURN ( evalm( a ) )
end proc
> translatie2D(tx,ty);
1 0 tx

0 1 ty


0 0 1
> linalg[inverse](translatie2D(tx,ty))=translatie2D(-tx,-ty);
1 0 tx 1 0 tx

0 1 ty 0 1 ty


0 0 1 0 0 1
> aplic_transf_lp:=proc(a,Lp)
> local i,j,k,n,d,lt;
> n:=nops(Lp);
> d:=nops(Lp[1]);
> lt:=[seq([seq(0,i=1..d)],j=1..n)];
> for k from 1 to n do
> for i from 1 to d do
> lt[k][i]:=0;
> for j from 1 to d do
> lt[k][i]:=lt[k][i]+a[i,j]*Lp[k][j]
> end do
> end do
> end do;
> RETURN(lt)
> end proc;
> aplic_transf_lp_nh:=proc(a,Lp)
> local i,j,k,n,d,lt,Lph;
> n:=nops(Lp);
> d:=nops(Lp[1]);Lph:=[seq([seq(Lp[i][j],j=1..d),1],i=1..n)];
> lt:=[seq([seq(0,i=1..d)],j=1..n)];
> for k from 1 to n do
Grafic asistat de calculator 2014

> for i from 1 to d do


> lt[k][i]:=0;
> for j from 1 to d+1 do
> lt[k][i]:=lt[k][i]+a[i,j]*Lph[k][j]
> end do
> end do
> end do;
> RETURN(lt)
> end proc;
aplic_transf_lp := proc(a, Lp)
local i, j, k, n, d, lt;
n := nops( Lp ) ;
d := nops( Lp[ 1 ] ) ;
lt := [ seq( [ seq( 0, i 1 .. d ) ], j 1 .. n ) ] ;

for k to n do for i to d do
lt[ k ][ i ] := 0;
RETURN ( lt )
for j to d do lt[ k ][ i ] := lt[ k ][ i ] a[ i, j ]Lp[ k ][ j ] end do
end proc
end do
end do ;
aplic_transf_lp_nh := proc(a, Lp)
local i, j, k, n, d, lt, Lph ;
n := nops( Lp ) ;
d := nops( Lp[ 1 ] ) ;
Lph := [ seq( [ seq( Lp[ i ][ j ], j1 .. d ), 1 ], i 1 .. n ) ] ;

lt := [ seq( [ seq( 0, i 1 .. d ) ], j 1 .. n ) ] ;
for k to n do for i to d do
lt[ k ][ i ] := 0;
for j to d 1 do lt[ k ][ i ] := lt[ k ][ i ] a[ i, j ]Lph [ k ][ j ] end do
end do

end do ;
RETURN ( lt )
end proc
>
> aplic_transf_lp(translatie2D(a,b),[[x,y,1]]);
Grafic asistat de calculator 2014

[ [ xa, yb, 1 ] ]
> aplic_transf_lp(translatie2D(a,b),[[x,y,1],[a,b,1]]);
[ [ xa, yb, 1 ], [ 2 a, 2 b, 1 ] ]

> aplic_transf_lp_nh(translatie2D(a,b),[[x,y],[a,b]]);
[ [ xa, y b ], [ 2 a, 2 b ] ]
>
> desen_transf:=proc(Lp,a)
> local lt,o1,o2,p;
> o1:=plots[pointplot](Lp,connect=true,color=COLOR(RGB,0,0,0));
> lt:=aplic_transf_lp_nh(a,Lp);
> o2:=plots[pointplot](lt,connect=true,color=COLOR(RGB,1,0,0));
> plots[display]([plots[pointplot]
([0,0]),o1,o2],axes=normal,scaling=constrained)
> end proc;
desen_transf := proc(Lp, a)
local lt, o1, o2, p;
o1 := plots[ pointplot ]( Lp, connect true, colorCOLOR ( RGB, 0, 0, 0 ) ) ;
lt := aplic_transf_lp_nh( a, Lp ) ;
o2 := plots[ pointplot ]( lt, connect true, color COLOR ( RGB, 1, 0, 0 ) ) ;

plots[ display ]( [ plots[ pointplot ]( [ 0, 0 ] ), o1, o2 ], axesnormal ,


scalingconstrained )
end proc
>
> casuta:=[[1,10],[1,1],[8,1],[8,10],[1,10],[4.5,17],[8,10]];
casuta := [ [ 1, 10 ], [ 1, 1 ], [ 8, 1 ], [ 8, 10 ], [ 1, 10 ], [ 4.5 , 17 ], [ 8, 10 ] ]
> desen_transf(casuta,translatie2D(10,9));
Grafic asistat de calculator 2014

> scalare2D:=proc(sx,sy)
> local a;
> a:=array(1..3,1..3,[[sx,0,0],[0,sy,0],[0,0,1]]);
> RETURN(evalm(a))
> end proc;
scalare2D := proc(sx, sy)
local a;
a := array( 1 .. 3, 1 .. 3, [ [ sx, 0, 0 ], [ 0, sy, 0 ], [ 0, 0, 1 ] ] ) ;
RETURN ( evalm( a ) )
end proc
> scalare2D(sx,sy);
sx 0 0

0 sy 0


0 0 1
> linalg[inverse](scalare2D(sx,sy))=scalare2D(1/sx,1/sy);
1 0
1
0
0 0
sx sx


1 1
0 0 0 0
sy sy


0 0 1 0 0 1
> desen_transf(aplic_transf_lp_nh(translatie2D(-casuta[2][1],-
casuta[2][2]),casuta),scalare2D(1/2,1/3));
Grafic asistat de calculator 2014

> desen_transf(aplic_transf_lp_nh(translatie2D(-casuta[2][1],-
casuta[2][2]),casuta),scalare2D(2,3));

>
>
> rotatie2D:=proc(theta)
> local a;
> a:=array(1..3,1..3,[[cos(theta),-sin(theta),0],
[sin(theta),cos(theta),0],[0,0,1]]);
> RETURN(evalm(a))
> end proc;
rotatie2D := proc()
local a;
a := array( 1 .. 3, 1 .. 3, [ [ cos( ), sin( ), 0 ], [ sin( ), cos( ), 0 ], [ 0, 0, 1 ] ] ) ;
RETURN ( evalm( a ) )
end proc
>
> rotatie2D(theta);
cos( ) sin( ) 0

sin( ) cos( ) 0


0 0 1
Grafic asistat de calculator 2014

> map(simplify,linalg[inverse](rotatie2D(theta)))=rotatie2D(-
theta);
cos( ) sin( ) 0 cos( ) sin( ) 0

sin( ) cos( ) 0 sin( ) cos( ) 0


0 0 1 0 0 1
> map(simplify,linalg[inverse]
(rotatie2D(theta)))=linalg[transpose](rotatie2D(theta));
cos( ) sin( ) 0 cos( ) sin( ) 0

sin( ) cos( ) 0 sin( ) cos( ) 0


0 0 1 0 0 1
> desen_transf(casuta,rotatie2D(Pi/3));

> desen_transf(casuta,rotatie2D(Pi/4));
Grafic asistat de calculator 2014

> desen_transf(casuta,rotatie2D(Pi/2));

> desen_transf(casuta,rotatie2D(-Pi/2));

> forfecare2D:=proc(fx,fy)
> local a;
> a:=array(1..3,1..3,[[1,fy,0],[fx,1,0],[0,0,1]]);
> RETURN(evalm(a))
> end proc;
forfecare2D := proc(fx, fy)
local a;
a := array( 1 .. 3, 1 .. 3, [ [ 1, fy, 0 ], [ fx, 1, 0 ], [ 0, 0, 1 ] ] ) ; RETURN ( evalm( a ) )
end proc
> forfecare2D(fx,fy);
1 fy 0

fx 1 0


0 0 1
Grafic asistat de calculator 2014

> linalg[inverse](forfecare2D(fx,fy));
1 fy
0
1 fx fy 1 fx fy


fx 1
0
1 fx fy 1 fx fy


0 0 1
> desen_transf(aplic_transf_lp_nh(translatie2D(-casuta[2][1],-
casuta[2][2]),casuta),forfecare2D(1,0));

> desen_transf(aplic_transf_lp_nh(translatie2D(-casuta[2][1],-
casuta[2][2]),casuta),forfecare2D(0,1));
Grafic asistat de calculator 2014

> desen_transf(aplic_transf_lp_nh(translatie2D(-casuta[2][1],-
casuta[2][2]),casuta),forfecare2D(2,1));

scalare in raport cu C(cx,cy)


> sc:=evalm(translatie2D(cx,cy)&*scalare2D(sx,sy)&*translatie2D(-
cx,-cy));
sx 0 sx cx cx

sc := 0 sy sy cy cy
0 0 1

> evalm(sc&*array([x,y,1]));
[ sx x sx cxcx, sy y sy cy cy, 1 ]
> scalare_c2D:=proc(sx,sy,c)
>
RETURN(evalm(translatie2D(c[1],c[2])&*scalare2D(sx,sy)&*translati
e2D(-c[1],-c[2])));
> end proc;
scalare_c2D := proc(sx, sy, c)
RETURN ( evalm( `&*`( `&*`( translatie2D( c[ 1 ], c[ 2 ] ), scalare2D( sx, sy ) ),
translatie2D( c[ 1 ], c[ 2 ] ) ) ) )
end proc
> desen_transf(casuta,scalare_c2D(1/2,1/3,[casuta[2][1],casuta[2]
[2]]));
Grafic asistat de calculator 2014

> desen_transf(casuta,scalare_c2D(1/2,1/3,[casuta[3][1],casuta[3]
[2]]));

> desen_transf(casuta,scalare_c2D(1/2,1/3,[casuta[6][1],casuta[6]
[2]]));
Grafic asistat de calculator 2014

>
>
rotatie in raport cu C(cx,cy)
> rc:=evalm(translatie2D(cx,cy)&*rotatie2D(theta)&*translatie2D(-
cx,-cy));
>
cos( ) sin( ) cos( ) cxsin( ) cy cx

rc := sin( ) cos( ) sin( ) cxcos( ) cy cy

0 0 1
> evalm(rc&*vector([x,y,1]));
[ cos( ) x sin( ) y cos( ) cxsin( ) cy cx,
sin( ) xcos( ) y sin( ) cx cos( ) cy cy, 1 ]
> rotatie_c2D:=proc(theta,c)
>
RETURN(evalm(translatie2D(c[1],c[2])&*rotatie2D(theta)&*translati
e2D(-c[1],-c[2])));
> end proc;
rotatie_c2D := proc(, c)
RETURN ( evalm( `&*`( `&*`( translatie2D( c[ 1 ], c[ 2 ] ), rotatie2D( ) ),
translatie2D( c[ 1 ], c[ 2 ] ) ) ) )
end proc
> rotatie_c2D(Pi/3,[1,2]);
1 3 1
3
2 2 2


3 1 3
1
2
2 2

0 0 1

Grafic asistat de calculator 2014

> desen_transf(casuta,rotatie_c2D(Pi/3,[casuta[2][1],casuta[2]
[2]]));

> desen_transf(casuta,rotatie_c2D(Pi/3,[casuta[3][1],casuta[3]
[2]]));

> desen_transf(casuta,rotatie_c2D(Pi/3,[casuta[6][1],casuta[6]
[2]]));
Grafic asistat de calculator 2014

> desen_transf(casuta,rotatie_c2D(Pi/2,[casuta[6][1],casuta[6]
[2]]));

> desen_transf(casuta,rotatie_c2D(-Pi/2,[casuta[6][1],casuta[6]
[2]]));
Grafic asistat de calculator 2014

>
matrice_vizualizare2D_sn:=proc(xmin,ymin,xmax,ymax,xemin,yemin,xe
max,yemax)
> local a;
> a:=translatie2D(xemin,yemin)&*scalare2D(xemax-xemin,yemax-
yemin)&*scalare2D(1/(xmax-xmin),1/(ymax-ymin))&*translatie2D(-
xmin,-ymin);
> RETURN(evalm(a))
> end proc;
matrice_vizualizare2D_sn := proc(xmin, ymin, xmax, ymax, xemin, yemin, xemax, yemax
)
local a;
a := `&*`( `&*`( `&*`( translatie2D( xemin, yemin ),
scalare2D( xemax xemin, yemaxyemin ) ),

scalare2D( 1/( xmaxxmin ), 1/( ymaxymin ) ) ),


translatie2D( xmin, ymin ) );
RETURN ( evalm( a ) )
end proc
>
matrice_vizualizare2D_sn(xmin,ymin,xmax,ymax,xemin,yemin,xemax,ye
max);
>
Grafic asistat de calculator 2014

>
evalm(matrice_vizualizare2D_sn(xmin,ymin,xmax,ymax,xemin,yemin,xe
max,yemax)&*vector([x,y,1]));
>
xemaxxemin
( xemaxxemin ) xmin
xemin
0
xmaxxmin xmax xmin

yemax yemin ( yemaxyemin ) ymin

0 yemin
ymax ymin ymax ymin


0 0 1
( xemaxxemin ) x ( xemaxxemin ) xmin xemin,

xmax xmin xmax xmin
( yemaxyemin ) y ( yemaxyemin ) ymin
yemin, 1
ymax ymin ymax ymin
>
>
matrice_vizualizare2D:=proc(xmin,ymin,xmax,ymax,xemin,yemin,xemax
,yemax)
> local a;
> a:=translatie2D(xemin,yemin)&*translatie2D(0,yemax-
yemin)&*scalare2D(1,-1)&*scalare2D((xemax-xemin)/(xmax-xmin),
(yemax-yemin)/(ymax-ymin))&*translatie2D(-xmin,-ymin);
> RETURN(evalm(a))
> end proc;
matrice_vizualizare2D := proc(xmin, ymin, xmax, ymax, xemin, yemin, xemax, yemax)
local a;
a := `&*`( `&*`( `&*`(
`&*`( translatie2D( xemin, yemin ), translatie2D( 0, yemax yemin ) ),
scalare2D( 1, -1 ) ), scalare2D( ( xemax xemin )/( xmax xmin ),

( yemax yemin )/( ymaxymin ) ) ), translatie2D( xmin, ymin ) );


RETURN ( evalm( a ) )
end proc
>
matrice_vizualizare2D(xmin,ymin,xmax,ymax,xemin,yemin,xemax,yemax
);
xemaxxemin
( xemaxxemin ) xmin
xemin
0
xmaxxmin xmax xmin

yemax yemin ( yemax yemin ) ymin

0 yemax
ymax ymin ymax ymin


0 0 1
>
Grafic asistat de calculator 2014

> matrice_vizualizare2D_( xmin, ymin, xmax, ymax, xemin, yemin, xemax, yemax )
>
evalm(matrice_vizualizare2D(xmin,ymin,xmax,ymax,xemin,yemin,xemax
,yemax)&*vector([x,y,1]));
( xemaxxemin ) x ( xemaxxemin ) xmin xemin,

xmaxxmin xmax xmin
( yemax yemin ) y ( yemax yemin ) ymin
yemax, 1
ymax ymin ymaxymin
> matrice_vizualizare2D(3,2,9,7,2,3,9,10);
7 -3
0
6 2

64
-7
0
5 5


0 0 1
>
> evalm(rotatie2D(theta)&*translatie2D(a,b));
cos( ) sin( ) cos( ) asin( ) b

sin( ) cos( ) sin( ) acos( ) b


0 0 1
> evalm(translatie2D(a,b)&*rotatie2D(theta));
cos( ) sin( ) a

sin( ) cos( ) b


0 0 1
>
>
aa:=evalm(translatie2D(a,b)&*rotatie2D(theta)&*matrice_vizualizar
e2D(xmin,ymin,xmax,ymax,xemin,yemin,xemax,yemax));
Grafic asistat de calculator 2014

aa :=
cos( ) ( xemax xemin ) , sin( ) ( yemaxyemin ) ,

xmax xmin ymax ymin
( xemax xemin ) xmin
cos( ) xemin
xmax xmin

( yemax yemin ) ymin


sin( ) yemax a
ymax ymin
sin( ) ( xemax xemin ) cos( ) ( yemax yemin )
, ,
xmax xmin ymaxymin

( xemax xemin ) xmin


sin( ) xemin
xmax xmin
( yemax yemin ) ymin
cos( ) yemax b
ymax ymin
[0 , 0 , 1]
> map(simplify,evalm(linalg[inverse](aa)));
cos( ) ( xmax xmin ) , sin( ) ( xmax xmin ) , ( xmin xemaxxemin xmax

xemax xemin xemax xemin
sin( ) b xmaxsin( ) b xmincos( ) a xmax cos( ) a xmin )/(

xemax xemin )

sin( ) ( ymax ymin ) , cos( ) ( ymax ymin ) , ( cos( ) b ymax



yemax yemin yemaxyemin
cos( ) b yminymin yemin yemax ymax sin( ) a ymax sin( ) a ymin )/( [ 0 , 0 , 1 ]

yemax yemin )

> matrice_trecere2D:=proc(theta,x0,y0)
> local mat;
> mat:=translatie2D(x0,y0)&*rotatie2D(theta);
> RETURN(evalm(mat))
> end;
matrice_trecere2D := proc(, x0, y0)
local mat;
mat := `&*`( translatie2D( x0, y0 ), rotatie2D( ) ) ; RETURN ( evalm( mat ) )
end proc
Grafic asistat de calculator 2014

> matrice_trecere2D(theta,x0,y0);
cos( ) sin( ) x0

sin( ) cos( ) y0


0 0 1
>
evalm(matrice_vizualizare2D(xmin,ymin,xmax,ymax,xemin,yemin,xemax
,yemax)&*matrice_trecere2D(theta,x0,y0));
cos( ) ( xemax xemin ) , sin( ) ( xemaxxemin ) ,

xmax xmin xmax xmin
( xemax xemin ) x0 ( xemax xemin ) xmin
xemin
xmaxxmin xmax xmin

sin( ) ( yemax yemin ) , cos( ) ( yemaxyemin ) ,



ymax ymin ymax ymin
( yemaxyemin ) y0 ( yemax yemin ) ymin
yemax
ymax ymin ymax ymin
[0 , 0 , 1]
>
> evalm(rotatie2D(theta)&*scalare2D(sx,sy));
cos( ) sx sin( ) sy 0

sin( ) sx cos( ) sy 0


0 0 1
> evalm(scalare2D(sx,sy)&*rotatie2D(theta));
cos( ) sx sin( ) sx 0

sin( ) sy cos( ) sy 0


0 0 1
>
evalm(scalare2D(1/sx,1/sy)&*rotatie2D(theta)&*scalare2D(sx,sy));
cos( ) sin( ) sy
0
sx

sin( ) sx

cos ( ) 0
sy


0 0 1
>
evalm(scalare2D(1/sx,1/sy)&*matrice_trecere2D(theta,x0,y0)&*scala
re2D(sx,sy));
Grafic asistat de calculator 2014

cos( ) sin( ) sy x0

sx sx

sin( ) sx y0

cos( )
sy sy


0 0 1
> evalm(matrice_trecere2D(theta,x0,y0)&*scalare2D(sx,sy));
cos( ) sx sin( ) sy x0

sin( ) sx cos( ) sy y0


0 0 1
> evalm(scalare2D(sx,sy)&*matrice_trecere2D(theta,x0,y0));
cos( ) sx sin( ) sx sx x0

sin( ) sy cos( ) sy sy y0


0 0 1
> evalm(translatie2D(x0,y0)&*scalare2D(sy,sx)&*rotatie2D(theta));
cos( ) sy sin( ) sy x0

sin( ) sx cos( ) sx y0

0 0 1

>
evalm(matrice_vizualizare2D(xmin,ymin,xmax,ymax,xemin,yemin,xemax
,yemax)&*matrice_trecere2D(theta,x0,y0)&*scalare2D(sx,sy));
cos( ) ( xemax xemin ) sx , sin( ) ( xemax xemin ) sy ,

xmax xmin xmaxxmin
( xemaxxemin ) x0 ( xemax xemin ) xmin
xemin
xmaxxmin xmax xmin

sin( ) ( yemax yemin ) sx , cos( ) ( yemax yemin ) sy ,



ymaxymin ymax ymin
( yemax yemin ) y0 ( yemax yemin ) ymin
yemax
ymax ymin ymaxymin
[0 , 0 , 1]
>
evalm(matrice_vizualizare2D(xmin,ymin,xmax,ymax,xemin,yemin,xemax
,yemax)&*matrice_trecere2D(theta,x0,y0));
Grafic asistat de calculator 2014

cos( ) ( xemax xemin ) , sin( ) ( xemaxxemin ) ,



xmax xmin xmax xmin
( xemax xemin ) x0 ( xemax xemin ) xmin
xemin
xmaxxmin xmax xmin

sin( ) ( yemax yemin ) , cos( ) ( yemaxyemin ) ,



ymax ymin ymax ymin
( yemaxyemin ) y0 ( yemax yemin ) ymin
yemax
ymax ymin ymax ymin
[0 , 0 , 1]

You might also like