
-----------------------------------
yazdmich
Thu Oct 10, 2013 4:26 pm

Parametric plotter
-----------------------------------

/*
setup and variable declarations
*/

View.Set ('graphics:778;778,offscreenonly')

const midx := maxx div 2
const midy := maxy div 2

type cart :
record
    m : array 0 .. 778, 0 .. 778 of boolean
    x : array 0 .. 778 of int
    y : array 0 .. 778 of int
    z : array 0 .. 778 of int
end record

var x, y, z : int
var map : array 0 .. 360 of cart

/*
begin program
*/

/*
begin render and capture
*/ 

for q : 0 .. 360
    cls
					/*
					begin render of frame
					*/
    for s : 0 .. midx
        for t : 1 .. midy
            map (q).x (s) := round (cosd (t) * s) + midx	%---------------------------------%
            map (q).y (t) := round (sind (s) * t) + midy	% calculate position of plot data %
            map (q).z (s) := t					                        %---------------------------------%
            x := map (q).x (s) - midx
            z := map (q).z (s)
            x := round (cosd (q) * x - sind (q) * z)	   % calculate rotation around y-axis
            map (q).x (s) := x + midx
            Draw.Dot(map(q).x(s), map(q).y(t), black)		% plot data
        end for
    end for
                                        /* 
					end render of frame
					*/

					/*
					begin capture of frame
					*/
    for i : 0 .. maxx
        for o : 0 .. maxy
            if whatdotcolour(i,o) = 7 then
                map(q).m(i,o) := true
            else
                map(q).m(i,o) := false
            end if
        end for
    end for
					/*
					end capture of frame
					*/

    View.Set ('title:Rendering: ' + realstr (round ((q / 360) * 1000) / 10, 3) + '% complete')      % update title bar to show rendering status
    View.Update
end for

/*
end render and capture
*/ 
    
cls
View.Update
Input.Pause

/*
begin playback
*/ 

loop
    for q : 0 .. 360
        cls
        for s : 0 .. maxx
            for t : 0 .. maxy
                if map(q).m(s,t) then
                    Draw.Dot (s, t, black)                    
                end if
            end for
        end for
        View.Update
    end for
    cls
    Input.Pause
end loop


-----------------------------------
Raknarg
Thu Oct 10, 2013 4:54 pm

RE:Parametric plotter
-----------------------------------
That's pretty cool. What exactly is it showing us?

-----------------------------------
yazdmich
Thu Oct 10, 2013 4:56 pm

Re: Parametric plotter
-----------------------------------
It plots a parametric surface, stores each frame in an array, calculates rotation around the y-axis, then plays back (all in the code comments)
EDIT
http://www.ks.uiuc.edu/Research/vmd/script_library/scripts/3dparplot/parsurf.jpg example
