1 function pts_transformed=points_trafo(model,glob)
2 %
function pts_transformed=points_trafo(model,glob)
4 %
function transforming points according to which macro-triangle they belong
9 % glob: n-by-2 list of the points which shall be transformed
12 % pts_transformed: n-by-2 list of transformed points
14 % needed fields in model:
18 % Oliver Zeeb, 16.02.11
20 nr_macro_tri = size(model.tmacro,1);
21 pmacro_ref = model.pmacro; % points of the reference macrogrid
22 tmacro = model.tmacro;
24 % use the mus
for setting the
new macrogrid-points
25 pmacro_reshaped = model.pmacro; % coordinates of the reshaped macrogrid
26 % old: 12.05.11: funktioniert so nur, wenn alle punkte parameter sind!
27 %
for k=1:nr_mus/2 % nr_mus = length(model.mu_names) should be even
28 % x = getfield(model, model.mu_names{k});
29 % y = getfield(model, model.mu_names{k+nr_mus/2});
30 % pmacro_reshaped(k,:) = [x,y];
33 for k=1:model.nr_macro_car_points
34 x = getfield(model, [
'x',num2str(k)]);
35 y = getfield(model, [
'y',num2str(k)]);
36 pmacro_reshaped(k,:) = [x,y];
40 %now the reshaped macropoints are set
42 if isequal(pmacro_reshaped,pmacro_ref) %no points were changed, still the original grid
44 disp(
' mu=mu_ref: no transformation needed!')
45 else %some macropoints were changed, so the points mus be transformed
46 %get the affine transformation for every macrogrid
47 disp(' transforming points... ')
48 C = zeros(2,nr_macro_tri);
49 G = zeros(2,2,nr_macro_tri);
51 tria_pts_ref = pmacro_ref(tmacro(k,:),:);
52 tria_pts_reshaped = pmacro_reshaped(tmacro(k,:),:);
53 [C(:,k), G(:,:,k)] = aff_trafo_coef(tria_pts_ref, tria_pts_reshaped);
55 %which point of the microgrid belongs to which macrotriangle?
56 pmic2tmac = pmicro2tmacro([glob(:,1),glob(:,2)], model);
59 pts_transformed = [glob(:,1)'; glob(:,2)'];
60 for k = 1:nr_macro_tri
61 pts_transformed(:,pmic2tmac==k) = repmat(C(:,k),1,length(pts_transformed(pmic2tmac==k)))...
62 + G(:,:,k)*pts_transformed(:,pmic2tmac==k);
64 pts_transformed = pts_transformed';