mardi 22 juin 2021

How to scatter randomly points on a sphere


using PyPlot
n = 50
u = range(0,stop=2*π,length=n);
v = range(0,stop=π,length=n);

x = cos.(u) * sin.(v)';
y = sin.(u) * sin.(v)';
z = ones(n) * cos.(v)';

scatter3D(vec(x),vec(y),vec(z);c="red",s=1)

enter image description here

However, if I multiply vec(x), vec(y), vec(z) with rand() ,
I still get the same plot with the only difference being that the axis change or in other words that the sphere gets "squished".


using PyPlot
n = 50
u = range(0,stop=2*π,length=n);
v = range(0,stop=π,length=n);

x = cos.(u) * sin.(v)';
y = sin.(u) * sin.(v)';
z = ones(n) * cos.(v)';

scatter3D(rand()*vec(x),rand()*vec(y),rand()*vec(z);c="red",s=1)

enter image description here




Aucun commentaire:

Enregistrer un commentaire