MATLAB: Find all integer values contained within an irregular volume

for loopMATLABperformancevectorisevectorizevolume

I'm setting up a 3D volume within which points will be distributed, and want to mark some areas as "inaccessible". The areas are generated using e.g. a parametric description of ellipsoids:
% starting parameters
axes = randi(10,1,3) ; % generate axes lengths
theta = linspace(-0.5*pi,0.5*pi) ; % eccentric anomaly
lambda = linspace(0,2*pi) ; % azimuthal angle
angles = combvec(theta,lambda) ; % all angles for evaluation
% evaluate ellipsoid points
points = axes .* [cos(angles(1,:)) .* cos(angles(2,:)) ; ...
cos(angles(1,:)) .* sin(angles(2,:)) ; ...
sin(angles(1,:))] ;
% convert to integers, find unique rows
unique_points = unique(floor(points), 'rows') ;
At this point, I have a set of integer points for an ellipsoid centred on the origin. But I would also like all integers contained within these points. Additionally, in the real version, these ellipsoids can be asymmetric across the origin, are rotated, and offset. They might also be cylinders. The shape is determined by the user at initialisation.
Lacking a precise equation to describe such an irregular shape, how can I find all integer values contained within the ellipsoid? The only way I can think of at the moment requires nested for-loops, which takes TIME. I suspect there is a way to vectorise this code, but I can't see it at the moment.
EDIT: clarified use of "irregular shape/volume" whilst giving an example ellipsoid.

Best Answer

I wonder if the functions inpolygon and inpolyhedron might be helpful here. See this post about finding the points inside a 3D volume as well.