1 function [C, G] = aff_trafo_loc2glob(x0, y0)
2 %
function [C, G] = aff_trafo_loc2glob(x0, y0)
4 %
function giving the coefficients
for the affine transformation
5 % from reference/local triangle to the original/global 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
7 % transformation is calculated for the standard triangle:
9 % (0,1) |\ /| (x0(3),y0(3))
11 % (0,0) |__\ (1,0) (x0(1),y0(1)) /__| (x0(2),y0(2))
13 % function giving c1, c2, g11, g12, g21, g22
14 % so: C=[c1; c2] and G=[g11, g12; g21, g22]
17 % x0: 3-by-1-list of the x values of the original/global triangle
18 % y0: 3-by-1-list of the y values of the original/global triangle
21 % affine transformation can be written as T(x) = C + G*x
25 % See also aff_trafo_glob2loc which gives the transformation in the other
26 % direction (global to local)
28 % Oliver Zeeb, 01.02.11
41 %matrices for transformation:
42 B_aff = [1, 0, x1, y1, 0, 0; ...
43 0, 1, 0, 0, x1, y1; ...
44 1, 0, x2, y2, 0, 0; ...
45 0, 1, 0, 0, x2, y2; ...
46 1, 0, x3, y3, 0, 0; ...
49 V_aff = [x0(1); y0(1); x0(2); y0(2); x0(3); y0(3)];
51 coef_vec = B_aff \ V_aff;
53 C = [coef_vec(1); coef_vec(2)];
54 G = [coef_vec(3), coef_vec(4); coef_vec(5), coef_vec(6)];