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