public override void Draw(Graphics g, MathItem mathItem, Func <double, int> scaleY, Func <double, int> scaleX) { double maxx = double.NaN; double max = double.NaN; foreach (PointD pt in mathItem.Trace.GetPointsBetweenMarkers(mathItem.Marker1, mathItem.Marker2)) { if (double.IsNaN(max)) { max = pt.Y; maxx = pt.X; } else if (pt.Y < max) { max = pt.Y; maxx = pt.X; } } if (!double.IsNaN(max)) { int x = scaleX(maxx); int y = scaleY(max); g.DrawCross(mathItem.Pen, new Point(x, y), 5); } }
public override object Calculate(MathItem mathItem) { double avg = 0; IEnumerable <PointD> pts = mathItem.Trace.GetPointsBetweenMarkers(mathItem.Marker1, mathItem.Marker2); foreach (PointD pt in pts) { avg += pt.Y; } return(avg / pts.Count()); }
public override object Calculate(MathItem mathItem) { double min = double.NaN; foreach (PointD pt in mathItem.Trace.GetPointsBetweenMarkers(mathItem.Marker1, mathItem.Marker2)) { if (double.IsNaN(min)) { min = pt.Y; } else if (pt.Y < min) { min = pt.Y; } } return(min); }
public override void Draw(Graphics g, MathItem mathItem, Func <double, int> scaleY, Func <double, int> scaleX) { double avg = 0; int px = 0; int py = 0; int x = 0; int y = 0; bool first = true; foreach (PointD pt in mathItem.Trace.GetPointsBetweenMarkers(mathItem.Marker1, mathItem.Marker2)) { avg = avg + (pt.Y - avg) / N; px = x; py = y; x = scaleX(pt.X); y = scaleY(avg); if (!first) { g.DrawLine(mathItem.Pen, px, py, x, y); } first = false; } }
public override void Draw(Graphics g, MathItem mathItem, Func <double, int> scaleY, Func <double, int> scaleX) { double k1 = 0; double k2 = 0; double k3 = 0; double k4 = 0; double xAvg = 0; double yAvg = 0; PointD[] points = mathItem.Trace.GetPointsBetweenMarkers(mathItem.Marker1, mathItem.Marker2).ToArray(); foreach (PointD pt in points) { k1 += pt.X * pt.Y; k2 += pt.X; k3 += pt.Y; k4 += Math.Pow(pt.X, 2); xAvg += pt.X; yAvg += pt.Y; } xAvg /= points.Length; yAvg /= points.Length; double a1 = ((points.Length * k1) - (k2 * k3)) / (points.Length * k4 - Math.Pow(k2, 2)); double a0 = yAvg - (a1 * xAvg); int x1 = scaleX(mathItem.Marker1.X); int x2 = scaleX(mathItem.Marker2.X); int y1 = scaleY(mathItem.Marker1.X * a1 + a0); int y2 = scaleY(mathItem.Marker2.X * a1 + a0); g.DrawLine(mathItem.Pen, x1, y1, x2, y2); }
public override object Calculate(MathItem mathItem) { return(mathItem.Marker2.X - mathItem.Marker1.X); }
public override object Calculate(MathItem mathItem) { return(0); }