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

P M p.muehlmann at gmail.com
Fri Jul 2 10:50:55 CEST 2021


.... the rotation can be realised by changing   "rotation_angles"  in a for
loop

.. creating the movie...maybe use scicv?

in a for loop
- set rotation angle
- display the graph
- save the actual graph as an image
- reload the image
- add image to frame


see code below:
Only draw back here:   the avi-file could not be played afterwards..and had
only 6kB in size.

I guess, this is because ffmpeg is missing on my PC, but I am pretty sure
that some scicv expert could solve this issue.

BR
Philipp

scicv_Init();
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);
f = figure();f.background = 8;scatter3d(x,y,z,msizes=4);a = gca();
// create the avi filevideoWriter = new_VideoWriter("F:\testAvi.avi",
CV_FOURCC('M', 'P', '4', '2'), 25, [400, 400]);
for i = 0:360
    a.rotation_angles = [60, i];

    // save the graph as image
    xs2png(f.figure_id, 'F:\testImg.bmp');

    // read image
    img = imread('F:\testImg.png', CV_LOAD_IMAGE_GRAYSCALE);

    // add image as frame to avi
    VideoWriter_write(videoWriter, img);
end
// free avi from memorydelete_VideoWriter(videoWriter);






Am Fr., 2. Juli 2021 um 00:22 Uhr schrieb Heinz Nabielek <
heinznabielek at me.com>:

> 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];
>
>
> ______________
> Dr Heinz Nabielek
> Schüttelstrasse 77A/11
> A-1020 Wien, Österreich
> Tel +43 1 276 56 13
> cell +43 677 616 349 22
> heinznabielek at me.com
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20210702/c59e0ac2/attachment.htm>


More information about the users mailing list