Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Parametric plotter
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
yazdmich




PostPosted: Thu Oct 10, 2013 4:26 pm   Post subject: Parametric plotter

Turing:

/*
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
Sponsor
Sponsor
Sponsor
sponsor
Raknarg




PostPosted: Thu Oct 10, 2013 4:54 pm   Post subject: RE:Parametric plotter

That's pretty cool. What exactly is it showing us?
yazdmich




PostPosted: Thu Oct 10, 2013 4:56 pm   Post subject: 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://en.wikipedia.org/wiki/Parametric_surface technical details
Posted Image, might have been reduced in size. Click Image to view fullscreen. example
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: