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 % function giving the coefficients for the affine transformation
4 % from original/global triangle to the reference/local one.
5 %
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``
8 %
9 % @verbatim
10 % triangle: /| (x0(3),y0(3)) (0,1) |\
11 % / | ---T---> | \
12 % (x0(1),y0(1)) /__| (x0(2),y0(2)) (0,0) |__\ (1,0)
13 % @endverbatim
14 %
15 % Parameters:
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
18 %
19 % Return values:
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]'
22 %
23 % See also aff_trafo_loc2glob() which gives the transformation in the other
24 % direction (local to global)
25 
26 % Oliver Zeeb, 01.02.11
27 
28 % standard triangle
29 x1 = 0;
30 y1 = 0;
31 x2 = 1;
32 y2 = 0;
33 x3 = 0;
34 y3 = 1;
35 
36 ref_coord = [x1; y1; x2; y2; x3; y3];
37 
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)];
44 
45 coef_vec = B_aff \ ref_coord;
46 
47 C = [coef_vec(1); coef_vec(2)];
48 G = [coef_vec(3), coef_vec(4); coef_vec(5), coef_vec(6)];
49 % c1 = coef_vec(1);
50 % c2 = coef_vec(2);
51 % g11 = coef_vec(3);
52 % g12 = coef_vec(4);
53 % g21 = coef_vec(5);
54 % g22 = coef_vec(6);