Skip to content

Instantly share code, notes, and snippets.

@dbuscombe-usgs
Created July 26, 2013 02:33
Show Gist options
  • Save dbuscombe-usgs/6085630 to your computer and use it in GitHub Desktop.
Save dbuscombe-usgs/6085630 to your computer and use it in GitHub Desktop.
generate a homogeneous 3-D Poisson spatial distribution
function [x,y,z] = csbinproc3d(xp, yp, zp, n)
x = zeros(n,1);
y = zeros(n,1);
z = zeros(n,1);
i = 1;
minx = min(xp);
maxx = max(xp);
miny = min(yp);
maxy = max(yp);
minz = min(zp);
maxz = max(zp);
cx = maxx-minx;
cy = maxy - miny;
cz = maxz - minz;
while i <= n
xt = rand(1)*cx + minx;
yt = rand(1)*cy + miny;
zt = rand(1)*cz + minz;
k = inhull([xt,yt,zt],[xp,yp,zp]);
if k == 1
% it is in the region
x(i) = xt;
y(i) = yt;
z(i) = zt;
i = i+1;
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment