rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
aff_trafo_glob2loc.m
1 function [C, G] = aff_trafo_glob2loc(x0, y0)
2 %function [C, G] = aff_trafo_glob2loc(x0, y0)
3 %
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
7 %
8 % triangle: /| (x0(3),y0(3)) (0,1) |\
9 % / | ---T---> | \
10 % (x0(1),y0(1)) /__| (x0(2),y0(2)) (0,0) |__\ (1,0)
11 %
12 % function giving c1, c2, g11, g12, g21, g22
13 % so: C=[c1; c2] and G=[g11, g12; g21, g22]
14 %
15 % input:
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
18 %
19 % output:
20 % affine transformation can be written as T(x) = C + G*x
21 % C: 2-by-1-vector
22 % G: 2-by-2-matrix
23 %
24 % See also aff_trafo_loc2glob which gives the transformation in the other
25 % direction (local to global)
26 %
27 % Oliver Zeeb, 01.02.11
28 
29 % standard triangle
30 x1 = 0;
31 y1 = 0;
32 x2 = 1;
33 y2 = 0;
34 x3 = 0;
35 y3 = 1;
36 
37 ref_coord = [x1; y1; x2; y2; x3; y3];
38 
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)];
45 
46 coef_vec = B_aff \ ref_coord;
47 
48 C = [coef_vec(1); coef_vec(2)];
49 G = [coef_vec(3), coef_vec(4); coef_vec(5), coef_vec(6)];
50 % c1 = coef_vec(1);
51 % c2 = coef_vec(2);
52 % g11 = coef_vec(3);
53 % g12 = coef_vec(4);
54 % g21 = coef_vec(5);
55 % g22 = coef_vec(6);