How to pick n random points on a sphere
8 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
Rik
2020 年 10 月 6 日
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
2020 年 10 月 6 日
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
回答 (1 件)
Teja Muppirala
2012 年 7 月 25 日
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 件のコメント
参考
カテゴリ
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!