Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (687;10)
- (12;20)
- (24;30)
- (10125;40)
- (0;50)
- (111;60)
- (-2;70)
- private ZedGraph.PointPair findPoint(ZedGraph.CurveItem curve, double x)
- {
- if (curve.NPts == 1)
- return curve.Points[0];
- // Look for the min and max value
- double min = curve.Points[0].X;
- double max = curve.Points[curve.NPts - 1].X;
- double delta = curve.Points[1].X - min;
- // Prevent error if mouse is out of bounds.
- if (x > max)
- x = curve.Points[curve.NPts - 1].X;
- else if (x < min)
- x = curve.Points[0].X;
- double index = (x - min) / delta;
- int nearestIndex = (int)Math.Round(index, 0);
- if (nearestIndex < curve.NPts)
- {
- return curve.Points[nearestIndex];
- }
- return curve.Points[curve.NPts - 1];
- }
- private ZedGraph.PointPair findPoint(ZedGraph.CurveItem curve, double x)
- {
- // Look for the min and max value
- double min = curve.Points[0].X;
- double max = curve.Points[curve.NPts - 1].X;
- // Prevent error if mouse is out of bounds.
- if (x <= min) return curve.Points[0];
- if (x >= max) return curve.Points[curve.NPts - 1];
- double delta = (max - min) / (curve.NPts - 1);
- int index = (int)Math.round((x - min) / delta, 0);
- Debug.Assert(Math.Abs(x - curve.Points[index].X) <= delta / 2, "Interpolation error");
- return curve.Points[index];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement