1 function [C, G] = aff_trafo_glob2loc(x0, y0)
2 %
function [C, G] = aff_trafo_glob2loc(x0, y0)
3 %
function giving the coefficients
for the affine transformation
4 % from original/global triangle to the reference/local one.
6 % In detail,
this implements a transformation of the type
7 % ``T_{i,aff}(x;\mu) = C_{i,aff}(\mu) + \sum_{j=1,2} G_{ij}^k(\mu) x_j \qquad i=1,2``
10 % triangle: /| (x0(3),y0(3)) (0,1) |\
12 % (x0(1),y0(1)) /__| (x0(2),y0(2)) (0,0) |__\ (1,0)
16 % x0: vector of size '3 x 1' holding x values of the original/global triangle
17 % y0: vector of size '3 x 1' holding y values of the original/global triangle
20 % C: matrix of size '2 x 1' with entries 'C=[c1; c2]'
21 % G: matrix of size '2 x 2' with entries 'G=[g11, g12; g21, g22]'
23 % See also aff_trafo_loc2glob() which gives the transformation in the other
24 % direction (local to global)
26 % Oliver Zeeb, 01.02.11
36 ref_coord = [x1; y1; x2; y2; x3; y3];
38 B_aff = [1, 0, x0(1), y0(1), 0, 0; ...
39 0, 1, 0, 0, x0(1), y0(1); ...
40 1, 0, x0(2), y0(2), 0, 0; ...
41 0, 1, 0, 0, x0(2), y0(2); ...
42 1, 0, x0(3), y0(3), 0, 0; ...
43 0, 1, 0, 0, x0(3), y0(3)];
45 coef_vec = B_aff \ ref_coord;
47 C = [coef_vec(1); coef_vec(2)];
48 G = [coef_vec(3), coef_vec(4); coef_vec(5), coef_vec(6)];