Professional Documents
Culture Documents
> 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 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 ) ) ;
> 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));
> 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 ) ),
>
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 ),
> 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
xemax xemin )
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
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