math plotting: graphics topic: how to create x-y plane
Author |
Message |
palue
|
Posted: Tue Nov 19, 2013 1:26 pm Post subject: math plotting: graphics topic: how to create x-y plane |
|
|
Hi there,
I know how to use the simple graphics library to plot a line or quadratic, but how would one be able to create the Cartesian plane, that is
put x-y axis with tic marks etc. Such that when one plots a line for example it is in the x-y plane.
Any help on this. Also if there are any samples of code, I would really appreciate it.
Regards,
Palue |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Insectoid
![](http://compsci.ca/v3/uploads/user_avatars/13760332514cbd0ce972eaa.jpg)
|
Posted: Tue Nov 19, 2013 1:29 pm Post subject: RE:math plotting: graphics topic: how to create x-y plane |
|
|
The x-y axis with ticks is just lines. You need to decide where to draw them. Then if you want to plot something, you need to translate or scale it to fit inside the screen. |
|
|
|
|
![](images/spacer.gif) |
palue
|
Posted: Tue Nov 19, 2013 1:39 pm Post subject: Re: math plotting: graphics topic: how to create x-y plane |
|
|
Hi there,
Thanks for the reply.
That would be quite a bit of programming if I have to generate the x-y plane from the ground up and have to worry about how to place
functions within my newly created x-y plane.
Instead of creating this from scratch, what I am asking is if there is math plotting library in the Turing programming language.
I am not thinking of creating my own x-y plane library.
So if someone knows if Turing has a math graphic plotting library, please let me know.
Thanks again!
P |
|
|
|
|
![](images/spacer.gif) |
Raknarg
![](http://compsci.ca/v3/uploads/user_avatars/3745510004d8be6689b92f.jpg)
|
Posted: Tue Nov 19, 2013 10:43 pm Post subject: RE:math plotting: graphics topic: how to create x-y plane |
|
|
There is no library, but it's not a monumental task. It would be good practice to try and make it yourself. In fact if you really need this done, I'd be willing to help you make it.
If you really don't want to do it, your best bet is find someone who has already done it and ask them for their code.
Is this for a school assignment? |
|
|
|
|
![](images/spacer.gif) |
Insectoid
![](http://compsci.ca/v3/uploads/user_avatars/13760332514cbd0ce972eaa.jpg)
|
Posted: Wed Nov 20, 2013 1:32 pm Post subject: RE:math plotting: graphics topic: how to create x-y plane |
|
|
Quote: That would be quite a bit of programming
No, it wouldn't. It's one or two functions at most. Let's say you want your plane to extend from -300 to +300 in the horizontal and -100 to +100 in the vertical and map it to the standard 600*400 output window. Create a function that takes x-y coordinates from your plane as input. It translates the x value to fit into the output window- in this case, a shift 300 pixels to the positive, so you draw the dot at x+300. The y value gets stretched and shifted: multiply it by 2 to stretch it to 400 pixels, and shift up by 200. So you draw the pixel's y value at 2y+200. Now, any time you need to draw a dot, just call this function.
code: | func drawDotToScale(int x, int y)
draw.Dot (x+300, 2*y+200)
end drawDotToScale |
This can be generalized to fit any plane to any window, and it can easily be modified to draw lines, boxes, and other shapes, but I'll leave that to you if you need it. |
|
|
|
|
![](images/spacer.gif) |
|
|