How to pick n random points on a sphere
6 views (last 30 days)
Show older comments
Hi all, Does anybody know how to pick N random points (in my case N=4) on a unit sphere. Then draw a line connecting these points on the unit sphere.This is what i have done till now :-
theta=linspace(0,2*pi,40);
phi=linspace(0,pi,40);
[theta,phi]=meshgrid(theta,phi);
rho=1;
x=rho*sin(phi).*cos(theta);
y=rho*sin(phi).*sin(theta);
z=rho*cos(phi);
mesh(x,y,z)
axis equal
grid on
ALPHA('clear'); % renders the sphere transparent
Please help
[EDITED, Jan, copied from comments - please add informations, which are required to understand the problem, in the question, not as comments or answers. Thanks!]
Suppose that I have created a unit sphere. Now I pick 4 random points on this unit sphere. Then I need to draw a line passing through these 4 points (thus forming a quadrilateral). Later if this is successful I would like to draw a plane passing through the center of the sphere. Finally it would like to know how many lines did the plane cut through on this sphere. Hope you understand now. Please help
5 Comments
Rik
on 6 Oct 2020
Comment posted as answer by Kelly Mariotto:
Hello,
Can please anyone give me the solution for the angles of 7 points on the sphere?
Thank you very much.
Kelly
Walter Roberson
on 6 Oct 2020
What is the question about 7 points in the sphere? Angles between what and what? Angles measured from what point of view? https://stackoverflow.com/questions/55734075/calculate-angle-between-3d-points-of-sphere-with-specific-center
Answers (1)
Teja Muppirala
on 25 Jul 2012
I also do not understand what you mean by connecting 4 points on a sphere, but to answer the first part of your question,
this is how you would generate random points on a sphere:
TH = 2*pi*rand(1,1e4);
PH = asin(-1+2*rand(1,1e4));
[X,Y,Z] = sph2cart(TH,PH,1);
plot3(X,Y,Z,'.','markersize',1)
axis equal vis3d
0 Comments
See Also
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!