1 function [C, G] = aff_trafo_glob2loc(x0, y0)
2 %
function [C, G] = aff_trafo_glob2loc(x0, y0)
4 %
function giving the coefficients
for the affine transformation
5 % from original/global triangle to the reference/local one,
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: /| (x0(3),y0(3)) (0,1) |\
10 % (x0(1),y0(1)) /__| (x0(2),y0(2)) (0,0) |__\ (1,0)
12 % function giving c1, c2, g11, g12, g21, g22
13 % so: C=[c1; c2] and G=[g11, g12; g21, g22]
16 % x0: 3-by-1-list of the x values of the original/global triangle
17 % y0: 3-by-1-list of the y values of the original/global triangle
20 % affine transformation can be written as T(x) = C + G*x
24 % See also aff_trafo_loc2glob which gives the transformation in the other
25 % direction (local to global)
27 % Oliver Zeeb, 01.02.11
37 ref_coord = [x1; y1; x2; y2; x3; y3];
39 B_aff = [1, 0, x0(1), y0(1), 0, 0; ...
40 0, 1, 0, 0, x0(1), y0(1); ...
41 1, 0, x0(2), y0(2), 0, 0; ...
42 0, 1, 0, 0, x0(2), y0(2); ...
43 1, 0, x0(3), y0(3), 0, 0; ...
44 0, 1, 0, 0, x0(3), y0(3)];
46 coef_vec = B_aff \ ref_coord;
48 C = [coef_vec(1); coef_vec(2)];
49 G = [coef_vec(3), coef_vec(4); coef_vec(5), coef_vec(6)];