Sèítání a násobení matic:

A:matrix([1,2,3],[4,5,6]);
B:matrix([7,8,9],[10,11,12]);

A+B;

A:matrix([1,2],[3,4]);
B:matrix([5,6,7],[8,9,10]);

A.B;

Transformace vektorové roviny:

load(draw)$

Úseèka AB:

A:matrix([1],[2]);
B:matrix([2],[1]);

v:B-A;

M:matrix([-1,0],[0,-1]);
C:M.A;
D:M.B;

w:D-C;
draw2d(
grid=true,
color=black,
points([[0,0]]),
color=red,
parametric(A[1,1]+t*v[1,1],A[2,1]+t*v[2,1],t,0,1),
color=blue,
parametric(C[1,1]+t*w[1,1],C[2,1]+t*w[2,1],t,0,1) 
)$

Trojúhelník  s vrcholu A,B,A+B:

A:matrix([1],[2]);
B:matrix([2],[1]);
C:A+B;

v1:B-A;
v2:C-A;
v3:C-B;

M:matrix([-1,0],[0,-1]);
D:M.A;
E:M.B;
F:M.C;

w1:E-D;
w2:F-D;
w3:F-E;
draw2d(
grid=true,
color=black,
points([[0,0]]),
color=red,
parametric(A[1,1]+t*v1[1,1],A[2,1]+t*v1[2,1],t,0,1),
parametric(A[1,1]+t*v2[1,1],A[2,1]+t*v2[2,1],t,0,1),
parametric(B[1,1]+t*v3[1,1],B[2,1]+t*v3[2,1],t,0,1),
color=blue,
parametric(D[1,1]+t*w1[1,1],D[2,1]+t*w1[2,1],t,0,1),
parametric(D[1,1]+t*w2[1,1],D[2,1]+t*w2[2,1],t,0,1),
parametric(E[1,1]+t*w3[1,1],E[2,1]+t*w3[2,1],t,0,1)
)$

Pøedpis transformace T ze znalosti obrazu dvou bodù A,B:

T:matrix([x11,x12],[x21,x22]);

A:matrix([1],[2]);TA:matrix([6],[3]);
B:matrix([2],[1]);TB:matrix([8],[7]);

T.A=TA;
T.B=TB;

eq1:T.A-TA; eq2:T.B-TB;

sol:solve([eq1[1,1],eq1[2,1],eq2[1,1],eq2[2,1]]);

M:subst(sol,T);M.matrix([x],[y]);

Kam mi to zobrazí trojúhelník?

A:matrix([1],[2]);
B:matrix([2],[1]);
C:A+B;

v1:B-A;
v2:C-A;
v3:C-B;

D:M.A;
E:M.B;
F:M.C;

w1:E-D;
w2:F-D;
w3:F-E;
draw2d(
grid=true,
color=black,
points([[0,0]]),
color=red,
parametric(A[1,1]+t*v1[1,1],A[2,1]+t*v1[2,1],t,0,1),
parametric(A[1,1]+t*v2[1,1],A[2,1]+t*v2[2,1],t,0,1),
parametric(B[1,1]+t*v3[1,1],B[2,1]+t*v3[2,1],t,0,1),
color=blue,
parametric(D[1,1]+t*w1[1,1],D[2,1]+t*w1[2,1],t,0,1),
parametric(D[1,1]+t*w2[1,1],D[2,1]+t*w2[2,1],t,0,1),
parametric(E[1,1]+t*w3[1,1],E[2,1]+t*w3[2,1],t,0,1)
)$

Skládání transformací:

M:matrix([-1,0],[0,-1]);
N:matrix([0,-1],[1,0]);

A:matrix([1],[2]);
B:matrix([2],[1]);
C:A+B;

D:M.A;E:M.B;F:M.C;

G:N.D;H:N.E;I:N.F;

v1:B-A;v2:C-A;v3:C-B;
w1:E-D;w2:F-D;w3:F-E;
z1:H-G;z2:I-G;z3:I-H;
draw2d(
grid=true,
color=black,
points([[0,0]]),
color=red,
parametric(A[1,1]+t*v1[1,1],A[2,1]+t*v1[2,1],t,0,1),
parametric(A[1,1]+t*v2[1,1],A[2,1]+t*v2[2,1],t,0,1),
parametric(B[1,1]+t*v3[1,1],B[2,1]+t*v3[2,1],t,0,1),
color=blue,
parametric(D[1,1]+t*w1[1,1],D[2,1]+t*w1[2,1],t,0,1),
parametric(D[1,1]+t*w2[1,1],D[2,1]+t*w2[2,1],t,0,1),
parametric(E[1,1]+t*w3[1,1],E[2,1]+t*w3[2,1],t,0,1),
color=green,
parametric(G[1,1]+t*z1[1,1],G[2,1]+t*z1[2,1],t,0,1),
parametric(G[1,1]+t*z2[1,1],G[2,1]+t*z2[2,1],t,0,1),
parametric(H[1,1]+t*z3[1,1],H[2,1]+t*z3[2,1],t,0,1)
)$

Afinní rovina:

Posunutí o libovolný vektor:

A:matrix([1],[2]);
B:matrix([2],[1]);
C:A+B;

v:matrix([1],[2]);

v1:B-A;
v2:C-A;
v3:C-B;

D:A+v;E:B+v;F:C+v;

w1:E-D;
w2:F-D;
w3:F-E;
draw2d(
grid=true,
color=black,
points([[0,0]]),
color=red,
parametric(A[1,1]+t*v1[1,1],A[2,1]+t*v1[2,1],t,0,1),
parametric(A[1,1]+t*v2[1,1],A[2,1]+t*v2[2,1],t,0,1),
parametric(B[1,1]+t*v3[1,1],B[2,1]+t*v3[2,1],t,0,1),
color=blue,
parametric(D[1,1]+t*w1[1,1],D[2,1]+t*w1[2,1],t,0,1),
parametric(D[1,1]+t*w2[1,1],D[2,1]+t*w2[2,1],t,0,1),
parametric(E[1,1]+t*w3[1,1],E[2,1]+t*w3[2,1],t,0,1)
)$

Symetrie podle støedu [1,2]

A:matrix([1],[2]);
B:matrix([2],[1]);
C:A+B;

M:matrix([-1,0],[0,-1]); v:matrix([2],[4]);

v1:B-A;
v2:C-A;
v3:C-B;

D:M.A+v;E:M.B+v;F:M.C+v;

w1:E-D;
w2:F-D;
w3:F-E;
draw2d(
grid=true,
color=black,
points([[1,2]]),
color=red,
parametric(A[1,1]+t*v1[1,1],A[2,1]+t*v1[2,1],t,0,1),
parametric(A[1,1]+t*v2[1,1],A[2,1]+t*v2[2,1],t,0,1),
parametric(B[1,1]+t*v3[1,1],B[2,1]+t*v3[2,1],t,0,1),
color=blue,
parametric(D[1,1]+t*w1[1,1],D[2,1]+t*w1[2,1],t,0,1),
parametric(D[1,1]+t*w2[1,1],D[2,1]+t*w2[2,1],t,0,1),
parametric(E[1,1]+t*w3[1,1],E[2,1]+t*w3[2,1],t,0,1)
)$

Pøedpis afinní transformace R ze znalosti obrazù tøí bodù A,B,C:

R:matrix([x11,x12],[x21,x22]);u:matrix([u1],[u2]);

A:matrix([1],[2]);A2:matrix([2],[2]);
B:matrix([2],[1]);B2:matrix([3],[1]);
C:matrix([3],[3]);C2:matrix([1],[1]);

R.A+u=A2;
R.B+u=B2;
R.C+u=C2;

eq1:R.A+u-A2; eq2:R.B+u-B2; eq3:R.C+u-C2;

sol:solve([eq1[1,1],eq1[2,1],eq2[1,1],eq2[2,1],eq3[1,1],eq3[2,1]]);

M:subst(sol,R);s:subst(sol,u);M.matrix([x],[y])+s;

Kam mi to zobrazí trojúhelník?

A:matrix([1],[2]);
B:matrix([2],[1]);
C:A+B;

v1:B-A;
v2:C-A;
v3:C-B;

D:M.A+s;
E:M.B+s;
F:M.C+s;

w1:E-D;
w2:F-D;
w3:F-E;
draw2d(
grid=true,
color=red,
parametric(A[1,1]+t*v1[1,1],A[2,1]+t*v1[2,1],t,0,1),
parametric(A[1,1]+t*v2[1,1],A[2,1]+t*v2[2,1],t,0,1),
parametric(B[1,1]+t*v3[1,1],B[2,1]+t*v3[2,1],t,0,1),
color=blue,
parametric(D[1,1]+t*w1[1,1],D[2,1]+t*w1[2,1],t,0,1),
parametric(D[1,1]+t*w2[1,1],D[2,1]+t*w2[2,1],t,0,1),
parametric(E[1,1]+t*w3[1,1],E[2,1]+t*w3[2,1],t,0,1)
)$

Afinní rovina jinak:

matrix([1,0,1],[0,1,2],[0,0,1]).matrix([-1,0,0],[0,-1,0],[0,0,1]).matrix([1,0,-1],[0,1,-2],[0,0,1]);