rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
geometry_transformation.m
1 function [X_trans, Y_trans] = geometry_transformation(X,Y,params)
2 %function [X_trans,Y_trans] = geometry_transformation(X,Y,params)
3 %
4 % function applying a geometry transformation function on the
5 % coordinates X,Y. The type of geometry manipulation is given through
6 % the params structure.
7 %
8 % required fields of params:
9 % geometry_transformation : 'spline', 'none'
10 % geometry_transformation_spline_x,
11 % geometry_transformation_spline_y : coordinates of interpolation for
12 % spline line in case of 'spline'
13 %
14 % optional fields of params:
15 % hill_height : if set it overwrites the y_hill(2)
16 %
17 % The different transformations:
18 % 'spline' transforms the upper line into a spline given by
19 % interpolation points. The points beneath this "hill" are linearly
20 % interpolated.
21 %
22 % Martin Drohmann 22.02.2008
23 
24 if isstruct(params) && ~isfield(params,'geometry_transformation')
25  params.geometry_transformation = 'none';
26 end
27 
28 if isequal(params.geometry_transformation, 'none')
29  X_trans = X;
30  Y_trans = Y;
31 elseif isequal(params.geometry_transformation, 'spline')
32  grid_y_min = params.yrange(1);
33  grid_height = params.yrange(2) - params.yrange(1);
34 
35  cs = spline_select(params);
36 
37 % transfunc_Y = @(X,Y) ( 1/grid_height + ppval(cs, X) ) ...
38 % .* (Y - grid_y_min) ...
39 % + grid_y_min;
40  transfunc_Y = @(X,Y) (Y-grid_y_min) ./ grid_height ...
41  .* (grid_height + ppval(cs,X)) ...
42  + grid_y_min;
43  X_trans = X;
44  Y_trans = transfunc_Y(X,Y);
45 else
46  error(['unknown method for geometry transformation: ', params.geometry_transformation]);
47 end
48 
49 %| \docupdate