Example #1
0
        public bool ContainsPoint(GraphPoint point)
        {
            for (int i = 0; i < Points.Count - 1; i++)
                if (Points[i].X <= point.X && Points[i + 1].X >= point.X)
                {
                    double x1 = Points[i].X;
                    double x2 = Points[i + 1].X;
                    double x = point.X;
                    double y1 = Points[i].Y;
                    double y2 = Points[i + 1].Y;
                    double y = point.Y;

                    double k = (y2 - y1) / (x2 - x1);
                    double b = y1 - k * x1;

                    if (Math.Abs((y - k * x) - b) < Precision * Math.Max(y1, y2))
                        return true;
                }

            return false;
        }
Example #2
0
 private Point TransformPoint(GraphPoint point)
 {
     return new Point(Convert.ToInt32((point.X - XBase) * (Width - GraphMargin*2) / XSize),
         Convert.ToInt32((point.Y - YBase) * (Height - GraphMargin*2) / YSize));
 }