Hello!

There is an equation for multimodal function. Need to build her schedule. The condition is this: to build a graph, use the SetPixel method (int x, int y, int color); (coordinates and color of the set pixel). The problem is that if you go along only one axis and set pixels, the graph is not fully drawn, and if on both, then extra work is done. On the network on this issue is only "Stand graphics online," etc. Has anyone encountered such a problem? Can you throw the literature or give the algorithm? Thank.

    2 answers 2

    Take any algorithm for drawing lines by points, for example, the Bresenham algorithm . Next, choose such an offset along the x axis, which would fall into each pixel (or after one or two — everything strongly depends on the function and its behavior). There, on Wikipedia, there are ready-made algorithms and code. For construction, they just use only the installation of pixels.

    If the appearance is unsatisfactory, then you will have to study the Bezier curves . But I think that this is not necessary.

      I did such a thing, but for equations of the second order only, so I can only give direction for the search. The decision depends on which function. You can either analyze the function and approximate it with parabolas, or create a tool for constructing a segment and line (x, f (x), x + step, f (x + step)). If the function does not exist at some point, problems will start with the second method.