Limits of sphere to obtain points
Show older comments
Hello everyone!
I have multiple points (nodes). And i plot (plot3) a sphere with coordinates of center x0,y0 and z0 with radius r. I need to obtain the points (nodes) which are inside in sphere. How i can do this? How i can obtain the limits of curvature of sphere (in x,y and z)?
Thanks!
code:
[x,y,z] = sphere();
plot3(r*x+x0, r*y+y0, r*z+z0,'k-')
2 Comments
Walter Roberson
on 10 May 2015
What data structure do you have to describe the nodes? For example is it a struct array each element of which is a structure with elements 'x', 'y', 'z', each a scalar?
Nuno
on 10 May 2015
Answers (1)
Walter Roberson
on 10 May 2015
0 votes
All of those nodes are on the outside of the sphere. None of them are inside the sphere.
7 Comments
Nuno
on 10 May 2015
Walter Roberson
on 10 May 2015
Because that is how the returned values of sphere are defined: they give coordinates of points on the surface of the sphere.
I suspect what you are trying to do is find the points that are inside the boundaries of a sphere drawn inside a cubic lattice, sort of the three dimension equivalent of the coordinates of the pixels inside a circle drawn into a two dimensional image. But in order to do that you need to define the size of your pixels as there would be many more pixels if the grid was -r:1/100:+r than there would be for -r:1/10:+r
Walter Roberson
on 10 May 2015
If you have a specific list of x, y, z and you wish to know which are inside the sphere then
insphere = (x-Xcenter).^2 + (y-Ycenter).^2 + (z-Zcenter).^2 < Radius.^2;
and the corresponding points are
xin = x(insphere);
yin = y(insphere);
zin = z(insphere);
Nuno
on 10 May 2015
Nuno
on 10 May 2015
Nuno
on 10 May 2015
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!