[Date Prev] [Date Next] [Thread Prev] [Thread Next] Date Index Thread Index Search archive:
Date:Mon Nov 28 11:12:16 2000 
Subject:RCLIB (rc_transform_pictures - for simple movies) 
From:Aaron Sloman See text for reply address 
Volume-ID:1001128.01 

[To reply replace "Aaron.Sloman.XX" with "A.Sloman"]

I previously wrote:

> I've now added a new facility to RCLIB, enabling you to "morph" a
> picture made of a set of lines ...
> ...
> rc_transform_lines(
>     coords1, coords2, steps, colour,
>         widthOrShape, mode, delay, trail, proc);
>
> coords1 and coords2 are lists (or vectors) of 2xN numbers representing
> N points defining an open or closed or filled polygon.

> ...
> A new library, LIB rc_pythagoras, giving a demonstration of the
> Chinese proof of pythagoras' theorem shows how the new transform
> procedure can be used. It presents the proof dynamically, by
> moving squares and triangles around.
>
> I shall later produce a variant of rc_transform_lines called
> perhaps rc_transform_picture ...

This now exists. Extract from HELP RCLIB describes it:

===================================================================
rc_transform_pictures(pics, steps, delay, trail);

This is used to create a display with several moving pictures
defined by collections of lines, etc. It repeatedly draws/re-draws a
collection of pictures specified in the list or vector pics.
They are drawn steps times with a pause of delay 100ths of a second
between each "frame". If trail is true the intermediate versions remain
drawn, otherwise they are deleted before the next frame.
(Compare rc_transform_lines)

pics:
    A vector or list of picture specifications, where each element is
    a vector or list, containing six items:
        startcoords, endcoords, colour, widthOrShape, mode, proc
    as follows:

        startcoords:
            a lists or vector of K sets of coordinates representing
            points defining the initial state of a sub-picture, to be
            drawn by proc. If the numbers represent 2-D coordinates then
            startcoords has length 2xK.

        endcoords:
            Similar to startcoords, but defines the final state of a
            subpicture

        colour:
            A string

        widthOrShape:
            If the procedure proc is rc_draw_lines_filled (or the word
            "FILLED" then this should be one of
                Convex, Nonconvex or Complex (See REF XpwPixmap)
            Otherwise value should be an integer representing width
            of lines or something interpreted by a user-supplied
            procedure proc

        mode:
            One of
                CoordModeOrigin:
                    coordinates are relative to the origin
                CoordModePrevious:
                    coordinates are relative to the previous point,
                    apart from the first point which is taken to be
                    relative to the origin.
                    See MAN??XDrawLine.
        proc:
            This can be one of the words "OPEN", "CLOSED" or "FILLED"
            interpreted as referring to the corresponding one of these
            procedures
                rc_draw_lines           -- for open polygons
                rc_draw_lines_closed    -- for closed polygons
                rc_draw_lines_filled    -- for filled polygons
            or it can be a procedure or a name of a procedure, as long
            as the procedure takes four arguments:
                a vector (e.g. like startcoords, etc.)
                a colour,
                two other arguments corresponding to widthOrShape
                    and mode as explained above

steps:
    An integer specifying how many intermediate pictures should be
    drawn between initial and final state.

delay:
    An integer specifying 100ths of a second delay between frames.

trail:
    A boolean. If false, rc_transform_pictures does not leave a "trail"
    of intermediate states visible, otherwise it does.


Examples of use of rc_transform_pictures
vars win1 =
        rc_new_window_object("right", "top", 500, 500, true, 'win1');

rc_transform_pictures(
    [
        [[0 200 50 50 50 100] [180 10 100 190 200 200]
            'blue' 4 ^CoordModeOrigin OPEN]

        [[-100 100 50 0 50 100] [200 -50 100 50 220 80]
            'red' ^Convex ^CoordModeOrigin FILLED]

        [[-150 -200 -50 -10 50 -100] [180 -150 200 -50 240 -200]
            'green' 6 ^CoordModeOrigin CLOSED]

    ],
    20, 1, false);

===================================================================
The above example produces open, filled, and closed, moving
triangles, coloured blue, red and green respectively, drawn in
20 steps with 1/100 sec delay, leaving no trail.

Code and documentation included in rclib.tar.gz at the free poplog
site:

    http://www.cs.bham.ac.uk/research/poplog/freepoplog.html

There's now a demonstration of rc_transform_pictures in
lib rc_pythagoras (library included in rclib/lib/rc_pythagoras)
which, as before, demonstrates the wordless "Chinese" proof of
pythagoras by moving tringles and squares around.
The new version ends with a demonstration that the proof is
shape independent, by gradually transforming all the shapes.

I suspect this sort of thing could be very useful in interactive
learning packages, for mathematics, physics, engineering, etc.

Using repeated calls of rc_transform_picture it may be possible to
generate interesting cartoon movies, if the movie can be easily
decomposed into portions between which linear interpolation
is acceptable.

The pythagoras example is inspired by one written in Java by Norman
Foo

   http://www.cse.unsw.edu.au/~norman/Pythag.html

That demo shows a proof in which the triangles rotate within a given
square. My demo has triangles moving without rotation into a new
square.  Both demos show shape independence by gradually morphing
triangles within a square.

Comments and suggestions welcome.

Aaron
===
Aaron Sloman, ( http://www.cs.bham.ac.uk/~axs/ )
School of Computer Science, The University of Birmingham, B15 2TT, UK
EMAIL A.Sloman AT cs.bham.ac.uk   (ReadATas@please !)
PAPERS: http://www.cs.bham.ac.uk/research/cogaff/
FREE TOOLS: http://www.cs.bham.ac.uk/research/poplog/freepoplog.html