Extract a sphere out of a cube

1 次查看(过去 30 天)
Hello, I have been working with points with specific distances and angles between them, because this properties are constants I can reproduce a large bulk of points, the problem is that so far I can only generate cuboids. What I need is to extract a sphere of a cube maintaining the location of the points, the easiest way that I can think of is something like define a sphere and cut-off the points outside of it, but I have no idea how to do that, any hint is very welcome.
Thank you

采纳的回答

Michael Haderlein
Michael Haderlein 2014-8-29
Do you mean something like this?
[X,Y,Z]=meshgrid(linspace(0,1,20),linspace(0,1,20),linspace(0,1,20));
x=X(:);y=Y(:);z=Z(:);
rem=((x-.5).^2+(y-.5).^2+(z-.5).^2)>.5^2;
x(rem)=[];y(rem)=[];z(rem)=[];
figure, scatter3(x,y,z)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by