![]() |
|
Math graph plot |
Alexandre Bencz
Member #15,257
August 2013
|
How can develop a system to draw on the screen the graph of a function? How is the best way to implement this ? ( this is just a ideia of code... )
|
StevenVI
Member #562
July 2000
![]() |
Using al_put_pixel at each sample point is one approach, but what you'll get is a series of dots. You might have better luck using a line between each sample point to fill in the in-between spaces. Also note that in Allegro, the origin is in the upper-left corner with x increasing to the right and y increasing to the bottom. The y coordinate is likely the inverse of how you typically think of the Cartesian plane. __________________________________________________ |
Alexandre Bencz
Member #15,257
August 2013
|
Hi StevenVI About use a line... if I need to drawn a parabola, or drawn a sine wave, I believe that for these cases, it would be better to put pixel by pixel, or would have some more efficient approach? |
StevenVI
Member #562
July 2000
![]() |
Sorry -- I'm not trying to confuse you, but I may be misunderstanding your intentions. If you want to draw a continuous curve, you'd want to use a line, because what you're actually doing is drawing a polygon that approximates the function using the finite pixels in your bitmap. Thus you'd use lines for each segment in the polygon. If you want to just see each sample point rather than an approximate curve, then you'd want to use pixels. __________________________________________________ |
|