1 function [C, G] = aff_trafo_coef(coord_1, coord_2)
2 %
function [C, G] = aff_trafo_coef(coord_1, coord_2)
4 %
function giving the coefficients
for the affine transformation
5 % from triangle 1 to triangle 2,
6 % i.e. T_i_aff(x;mu) = C_aff_i(mu) + sum_j=1_2 G_ij_k(mu) x_j; j=1,2, i=1,2
8 % triangle 1 /| (x1(3),y1(3)) (x2(3),y2(3)) |\ triangle 2
10 % (x1(1),y1(1)) /__| (x1(2),y1(2)) (x2(1),y2(1)) |__\ (x2(2),y2(2))
12 %
function giving c1, c2, g11, g12, g21, g22
13 % so: C=[c1; c2] and G=[g11, g12; g21, g22]
16 % coord_1: coordinates of triangle 1, 3-times-2 matrix
17 % coord_2: coordinates of triangle 2, 3-times-2 matrix
20 % affine transformation can be written as T(x) = C + G*x
25 % Oliver Zeeb, 07.02.11
46 tria_2_coord = [x2(1); y2(1); x2(2); y2(2); x2(3); y2(3)];
48 B_aff = [1, 0, x1(1), y1(1), 0, 0; ...
49 0, 1, 0, 0, x1(1), y1(1); ...
50 1, 0, x1(2), y1(2), 0, 0; ...
51 0, 1, 0, 0, x1(2), y1(2); ...
52 1, 0, x1(3), y1(3), 0, 0; ...
53 0, 1, 0, 0, x1(3), y1(3)];
55 coef_vec = B_aff \ tria_2_coord;
57 C = [coef_vec(1); coef_vec(2)];
58 G = [coef_vec(3), coef_vec(4); coef_vec(5), coef_vec(6)];