I am working on a math function sketcher program. Functions are being entered by user and the program parses them and draws their curves. I am facing a problem that, there are some functions that have a small range interval, such as sin(x), cos(x) which have only [-1 : 1] interval. In contrast, some other functions have a very large interval, such as e^x, so they grow up very fast. I am using X-axis values to evaluate in function to produce Y-access values. The X-axis values are usually fixed from -40 to 40. However, I cannot depend on fixed values for Y-access set like X-access, since some functions have a very large Y values and some other have a very small values.
I have tried to zoom the curve with multiplication\division approach, and it worked fine with common functions. For example, sin(x) is being zoomed by sin(x) * 3. However, I have found out that some functions don’t zoom up when multiplied by a factor, but rather, the function itself changes. An example is f(x) = sin(log(cosh(sec(-x)))).
I want to find a way to zoom the function curves out\in, so that I can adjust Y-access maximum, minimum and incremental step values of them, and ofcourse, zoom the curve such that it reaches the maximum\minmum Y-values. Any math\programming idea will do. Thanks
Uses: System.Drawing.Graphics.DrawCurve(Pen pen, PointF[] curve)
Transformation matrix works fine for me. You could try it and see:
Note:
I strongly believe this kind of operations (zoom in and out) should be performed on the view, not the model. The zoom operations should be performed on the graphics object or as some others call it, the screen. Changing the method you are rendering in my mind is not clean as you are changing the model, hence drawing a different mathematical function.