MATLAB Examples

Writing the geometry definition (from Matlab) with a grid of scattered points

This is an example where a grid of scattered points is to be written with a geometry. The geometry used comes from the example #1 of EABE_v34_p30. This set of points is used for the demo on interpolation with a scattered set of points.


Creation of the grid where the function is known

% Definition of the geometry
obj = obj_AFP_V1_00;
obj.file_geom_definition = 'R_fcts_geom\Files_geom_definition\EABE_v34_p30_ex1'; % Shape of the geometry

% Analysis of the geometry
obj = Analyse_geometry_definition(obj);

% Generation of a random set of points on the rectangular domain ([0 11],[0 7])
Nb_pts_by_unit_length_each_dimension = 4;
Nb_pts_x = 11*Nb_pts_by_unit_length_each_dimension;
Nb_pts_y = 7*Nb_pts_by_unit_length_each_dimension;
Nb_pts_rectangular_domain = Nb_pts_x*Nb_pts_y;
Pts_rand_x = 11*rand(Nb_pts_rectangular_domain,1); % To cover the length [0 11]
Pts_rand_y = 7*rand(Nb_pts_rectangular_domain,1); % To cover the length [0 7]
Pts_z = zeros(Nb_pts_rectangular_domain,1); % Even when working in 2D, the "z" coordinate should be given for points
% distributions.
Pts_coord_to_determine = [Pts_rand_x Pts_rand_y Pts_z]; % These are the points on the whole rectangular domain. Some of these
% points are outside the limits of the geometry.

% Determination of the points inside the geometry
L_pts_inside = Determine_pts_inside(obj,Pts_coord_to_determine);
Pts_coord_to_keep = Pts_coord_to_determine(L_pts_inside,:);


h = plot(obj); % Plot of the geometry
hold on
plot(Pts_rand_x,Pts_rand_y,'b.'); % Distribution on the rectangular area (blue points)
h_pts_kept = plot(Pts_coord_to_keep(:,1),Pts_coord_to_keep(:,2),'ro'); % Distribution of the kept points (those inside the
% geometry are encircled in red)

title('Geometry and scattered grid')

Writing the geometry information with the grid

obj = calc_pts_distr(obj,'replace',Pts_coord_to_keep); % The grid to write in the file is the one in |Pts_coord| (filled by
% the use of |calc_pts_distr|).

Copyright 2013 Mathieu Gendron