How to implement grapher in c #

So, I am writing a graphing calculator. While I have a semi-functional graph, it’s hard for me to find a good balance between accurate graphs and smooth curves.

The current implementation (semi-pseudo-code) looks something like this:

for (float i = GraphXMin; i <= GraphXMax; i++)
{
    PointF P = new PointF(i, EvaluateFunction(Function, i)
    ListOfPoints.Add(P)
}
Graphics.DrawCurve(ListOfPoints)

The problem is that it only adds a point to each integer value, the graphs are ultimately distorted when their turning points do not fall into integers (for example, sin (x) ^ 2).

alt text

I tried to increase I by something smaller (for example 0.1), which works, but the graph looks very rough.

alt text

# GDI+. SmoothingMethod AntiAlias, , . - ? , , ?

, - , ? , - ? 1/ ^ 2

P.S. , - .

+5
2

, . - int, float.

+1

, , .

:

  • ; .
  • . a b . ( !) ( ).

API, WPF Silverlight, .

. , , "" .

+2

All Articles