Limits of sphere to obtain points

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

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?
I have the coordinates of nodes (x,y and z) And with this i represent them in plot3

Sign in to comment.

Answers (1)

All of those nodes are on the outside of the sphere. None of them are inside the sphere.

7 Comments

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
Nuno
Nuno on 10 May 2015
Edited: Nuno on 10 May 2015
I have about 654,000 points. And, for example:
I want to draw (in plot3) a sphere at the center x = 169; y = 215; z=216 with radius 19. The points that are within a sphere, I can not know what?
I do not need to know the sphere limits / boundaries and then with a loop through the array (that have all the coordinates x, y and z of points) and see what are inside the limits?
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);
Thanks ! I will try
Work i guess :D
VERY THANK YOU Walter :D

Sign in to comment.

Tags

Asked:

on 10 May 2015

Commented:

on 10 May 2015

Community Treasure Hunt

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

Start Hunting!