필터 지우기
필터 지우기

How to pick n random points on a sphere

조회 수: 15 (최근 30일)
Vinita
Vinita 2012년 7월 25일
댓글: Walter Roberson 2020년 10월 6일
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
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
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
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

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by