[Scilab-users] How can I make a movie that shows how the sphere rotates around the z-axis?

Heinz Nabielek heinznabielek at me.com
Mon Jul 5 00:27:17 CEST 2021


Thanks for all the help from the group and saving the animation works well.
However [had somebody noticed?], there was an error in the statistical formulation to generate a uniform random point distribution within the sphere. The more correct (but perhaps clumsy) version is below.
Heinz


R=23;
N=14500;
nmax=1.1*6*N/%pi;
// Random points in cube 2R*2R*2R
x=grand(nmax,1,'unf',-R,R);
y=grand(nmax,1,'unf',-R,R);
z=grand(nmax,1,'unf',-R,R);
R2=R*R;
// Exclude points outside of sphere with radius R
T=(x^2+y^2+z^2)>R2;
M=[x y z];
M(T,:)=[];
[r c]=size(M);
M(((N+1):r), :)=[];
x=M(:,1); y=M(:,2); z=M(:,3); 
f = figure();
f.background = 8;
s = linspace(5, 1, N);
scatter3d(x,y,z,msizes=1,s);
a = gca();
outgif = "Sphere01.gif";
idGif = animaGIF(gcf(), outgif, ,2);
for i = 20:60;
    a.rotation_angles = [45, i];
    idGif = animaGIF(gcf(), idGif); // Adds the current figure to the GIF stream
end;
animaGIF(idGif);    // Closes the GIF stream




> On 02.07.2021, at 00:15, Heinz Nabielek <heinznabielek at me.com> wrote:
> 
> Colleagues:
> 
> the code below generates 14,500 random points in a spherical volume.
> How can I make a movie that shows how the sphere rotates around the z-axis? And how do I store the animation? animaGIF does not exist on my Scilab 6.1 in my macOS 10.15.7
> 
> Heinz
> 
> 
> R=23;
> N=14500;
> r=grand(N,1,'unf',0,R);
> phi=grand(N,1,'unf',0,2*%pi);
> theta=grand(N,1,'unf',0,%pi);
> x=r.*cos(phi).*sin(theta);
> y=r.*sin(phi).*sin(theta);
> z=r.*cos(theta);
> scatter3d(x,y,z,msizes=4);
> gca().rotation_angles = [60, 60];

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20210705/83520105/attachment.htm>


More information about the users mailing list