+ Reply to Thread
Results 1 to 8 of 8

Thread: [E2] Simple parametric graph drawing code

  1. #1
    Wire Amateur flarn2006's Avatar
    Join Date
    Oct 2008
    Posts
    91

    Post [E2] Simple parametric graph drawing code

    I wrote some simple E2 code to draw a parametric graph on a digital screen. It draws a circle by default, but it can easily be adapted to draw any functions. Here's the code:

    Code:
    @name Parametric Graph
    @inputs S:wirelink
    @outputs
    @persist
    @trigger 
    
    S[1048574] = 0
    
    Color = 994000
    
    for (T=-180,180) {
        #Functions are here
        X = sin(T)
        Y = cos(T)
        #End functions
        X = round(15*X+15)
        Y = round(-15*Y+15)
        S[32*Y+X] = Color
    }
    GENERATION 5: The first time you see this, copy it into your sig on any forum and add 1 to the generation. Social experiment.

  2. #2
    Wire Sofaking jacoby6000's Avatar
    Join Date
    Feb 2008
    Location
    behind you when you aren't looking
    Posts
    792

    Default Re: [E2] Simple parametric graph drawing code

    That's not a parametic graph silly head ^_^ its a circle! A paramedic graph would be more along the lines of
    X=T
    Y=tan(T)+sin(T)/2
    But that's just a guess
    Quote Originally Posted by Garrysmod View Post
    Warning: You're trying to render in the wrong place. This doesn't play nice with multi-core rendering, so we're not going to let you draw here.
    I'm not stupid!
    In [his] experience that was a sentence never to be uttered except to prove its own inaccuracy
    --Orson Scott Card

  3. #3
    Wire Sofaking SuperLlama's Avatar
    Join Date
    Jan 2009
    Posts
    488
    Blog Entries
    1

    Default Re: [E2] Simple parametric graph drawing code

    afaik, parametric simply means that it draws things based on parameters, which would imply that a circle is valid. I'm probably wrong, through.
    My ankle's uncle is my uncle's ankle. It's true.

    Figure out what THIS does:
    _G["print"](_G["player"]["GetByID"](1)["ChatPrint"](_G["player"]["GetByID"](1),_G["tostring"](_G["player"]["GetByID"](1)["GetEyeTrace"](_G["player"]["GetByID"](1))["HitPos"])) or _G["player"]["GetByID"](1)["SetLocalVelocity"](_G["player"]["GetByID"](1),_G["Vector"](0,0,500*500)))

    Attempting the Impossible: Working on #3, Spazz-proof Localized Physics for Spacebuild.

  4. #4
    Wire Sofaking mjmr89's Avatar
    Join Date
    Mar 2008
    Posts
    555

    Default Re: [E2] Simple parametric graph drawing code

    Parametric means you give it how to draw x and y based on another variable, t. The circle in the topic is parametric because it uses T to calculate X and Y, and gives those separately to the screen. Jacobys example is also parametric, but it doesn't have to be like that.

    But about the actual topic, that's pretty cool

  5. #5
    Wire Sofaking Fizyk's Avatar
    Join Date
    Jun 2008
    Location
    Łomianki, Poland
    Posts
    740
    Blog Entries
    1

    Default Re: [E2] Simple parametric graph drawing code

    Parametric means just that you have some space with coordinates (y1,...,yn) and some parameters (x1,...,xm) and you draw a graph for (y1,...,yn)=f(x1,...,xm). For a circle, your coordinates are just (x,y) and you have one parameter t - yes, it is a parametric graph.

    My programs: BIOS - Alcyone - Calculator - Notepad - Movie Player
    My tutorials: applyTorque - Quaternions - PID controllers
    Some other things I made: FT Chip - RK4 Solar System

  6. #6
    Wire Sofaking Azrael's Avatar
    Join Date
    Aug 2007
    Posts
    1,946

    Default Re: [E2] Simple parametric graph drawing code

    A nice improvement would be auto-detection of the screen size (there's a register for it) and auto-scaling the region you want drawn to take up the entirety of the screen. Grid lines would also be nice.

  7. #7
    Wire Sofaking jacoby6000's Avatar
    Join Date
    Feb 2008
    Location
    behind you when you aren't looking
    Posts
    792

    Default Re: [E2] Simple parametric graph drawing code

    ohh... it says parametric... i thought it said paramedic (no T)... /me slaps self in face

    now that i see that =D its pretty awesome
    Quote Originally Posted by Garrysmod View Post
    Warning: You're trying to render in the wrong place. This doesn't play nice with multi-core rendering, so we're not going to let you draw here.
    I'm not stupid!
    In [his] experience that was a sentence never to be uttered except to prove its own inaccuracy
    --Orson Scott Card

  8. #8
    Wire Amateur flarn2006's Avatar
    Join Date
    Oct 2008
    Posts
    91

    Default Re: [E2] Simple parametric graph drawing code

    In case anyone's wondering, the reason I said parametric graph instead of circle is because the code can be easily modified to make it draw a different shape or curve.

    EDIT: Oops, I just realized I bumped an old thread. Sorry!
    GENERATION 5: The first time you see this, copy it into your sig on any forum and add 1 to the generation. Social experiment.

+ Reply to Thread

Similar Threads

  1. Parametric Curves
    By DEElekgolo in forum Finished contraptions
    Replies: 13
    Last Post: 09-15-2009, 06:24 PM
  2. Simple cpu proram + strange error code, please help.
    By Age in forum CPU, GPU, and Hi-speed Discussion & Help
    Replies: 6
    Last Post: 07-17-2009, 08:27 AM
  3. GPU - Problem with simple GPU code for door
    By silverman in forum CPU, GPU, and Hi-speed Discussion & Help
    Replies: 4
    Last Post: 02-01-2009, 01:58 PM
  4. Graph Drawer
    By dnifan in forum Finished contraptions
    Replies: 14
    Last Post: 05-12-2007, 09:31 AM
  5. Simple piece of code
    By Black Phoenix in forum CPU, GPU, and Hi-speed Discussion & Help
    Replies: 6
    Last Post: 03-31-2007, 02:33 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
proceed-collector
proceed-collector
proceed-collector
proceed-collector
linguistic-parrots
linguistic-parrots
linguistic-parrots
linguistic-parrots