Archived

This topic is now archived and is closed to further replies.

wolfbane

Screen coords

Recommended Posts

wolfbane    122
I was wondering how to translate mathematical graphing coordinates, ex when the x and y are in the range -10 and 10 and the equation y=x*x will draw a simple parabola on the screen, into the scren coordinates? Since the screen coords go to the right and down and the input could only be ints, how do I adjust for scale and direction of the y? I am basicly trying to plot points on the scren of a simple parabola just like I mentioned earlier. Any help would be much appreciated.

Share this post


Link to post
Share on other sites
S1CA    1418
The simplest way is to use floating point numbers for all input and intermediate values and then simply convert to integer just before plotting to the screen.

If you can''t use floating point (for example you''re on a system such as GameBoy Advance), then the next best thing is "fixed point" where you set aside a certain number of bits in an integer to be the fractional part of the number. [Do a search and you''ll find some tutorials and complete explanations].

One nice advantage of using real numbers is you can do things like anti-aliasing quite cheaply.

--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
Could someone please post an example of how to get the coordinate system setup. I want to be able to input an equation such as y = x*x and have the output be a parabola. I have been trying to figure this out but I am a novice and am having much difficulty. Pease help!

Share this post


Link to post
Share on other sites
wolfbane    122
Could someone please post an example of how to get the coordinate system setup. I want to be able to input an equation such as y = x*x and have the output be a parabola. I have been trying to figure this out but I am a novice and am having much difficulty. Pease help!

Share this post


Link to post
Share on other sites