<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">Le 30/01/2017 à 00:25, Max Rossi a
écrit :<br>
</div>
<blockquote cite="mid:1485732346156-4035420.post@n3.nabble.com"
type="cite">
<pre wrap="">Hi all,
I'm trying to plot in Scilab the surface error of different non rectangular
panels (see attachments).
At a certain point of my code, everything is turned into nice XYZ data but
the only way I found to plot the data is to generate a grid and fit the Z
above it as follows:
tl_coef = cshep2d(XYZ);
xpx = round((max(X)-min(X))/pix_size);
ypx = round((max(Y)-min(Y))/pix_size);
vx = linspace(min(X),max(X),xpx);
vy = linspace(min(Y),max(Y),ypx);
[Xg,Yg] = ndgrid(vx,vy);
map1 = eval_cshep2d(Xg,Yg, tl_coef);
When the panel is not rectangular or circular I'm in trouble assigning %nan
to points that are inside the grid but outside the panel XY measured
locations.
Is there any smart way to manage the problem?
</pre>
</blockquote>
<br>
Hello, <br>
<br>
<i>If I understand well, you want a way to put Nan for those<br>
grid points which are far from interpolation points (because<br>
the values got by cshep2d are not really meaningful due to<br>
large errors) ? For "exterior points", assuming the interpolation<br>
region is more or less convex a possibility would be to compute<br>
the convex-hull of the (x-y coordinates) interpolation points and<br>
to test if each grid point is inside but I 'm not sure you can do<br>
that immediatly with scilab : the convex hull function was part
of<br>
metanet which is not embedded in scilab since a while, maybe<br>
it is still available through atoms. Btw I don't remenber if
there<br>
is a "inside polygon test" in scilab.<br>
<br>
Otherwise you could try a force brute method (which could be<br>
accelerated) by computing the minimal distance between each grid<br>
point to the interpolations points and discarding those which<br>
are too far. This can be done like this : (assuming that X and Y<br>
are the coordinates of the interpolation points)<br>
<br>
[Xg,Yg] = ndgrid(vx,vy);<br>
Zg = eval_cshep2d(Xg,Yg, tl_coef);<br>
<br>
// compute distance betwen grid and interpolation points<br>
ngp = size(Zg,"*")<br>
dmin = zeros(Zg)<br>
for k = 1:ngp <br>
dmin(k) = sqrt(min( (Xg(k) - X).^2 + (Yg(k) - Y).^2) )<br>
end<br>
<br>
// discard points which are too far<br>
threshold_dist = 0.1 // to be set adequately...<br>
Zg(dmin > threshold_dist) = %nan<br>
<br>
<br>
hth<br>
Bruno<br>
<br>
<br>
<br>
<br>
<br>
</i><i></i>
</body>
</html>