I would like to sample N points (lets say N = 10000) on a sphere.
I know how to plot a 3D sphere. However, I am not sure how to use spherical coordinates for points.
(below is the code I used for the sphere)
JavaScript
x
13
13
1
using PyPlot
2
n = 100
3
u = range(0,stop=2*π,length=n);
4
v = range(0,stop=π,length=n);
5
6
x = cos.(u) * sin.(v)';
7
y = sin.(u) * sin.(v)';
8
z = ones(n) * cos.(v)';
9
10
11
surf(x,y,z, rstride=4, cstride=4)
12
13
Advertisement
Answer
This will do the job:
JavaScript
1
3
1
scatter3D(vec(x),vec(y),vec(z);c="red",s=2)
2
surf(x,y,z, rstride=4, cstride=4)
3