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
0 个评论
采纳的回答
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 Center 和 File Exchange 中查找有关 Surface and Mesh Plots 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!