protected override List <Point2D> GeneratePoint2DList(Hyperbola hyper) { List <Point2D> list = new List <Point2D>(); int x = hyper.a; int y = 0; int a = hyper.a; int b = hyper.b; int a2 = a * a; int b2 = b * b; int xprev = x; int yprev = y; // First Half while (Math.Abs(x * b2) >= Math.Abs(y * a2) && x <= hyper.limit) { if (hyper.orientation == Orientation.Horizontal) { list.Add(new Point2D(x, y)); } else { list.Add(new Point2D(-y, x)); } xprev = x; yprev = y; y += 1; x = (int)Math.Round(Math.Sqrt((double)a2 * y * y / b2 + a2)); } // Second Half x = xprev; y = yprev; while (x <= hyper.limit) { if (hyper.orientation == Orientation.Horizontal) { list.Add(new Point2D(x, y)); } else { list.Add(new Point2D(-y, x)); } x += 1; y = (int)Math.Round(Math.Sqrt((double)b2 * x * x / a2 - b2)); } return(Generate4SymmetricPoint2D(list, hyper.center)); }
protected override List <Point2D> GeneratePoint2DList(Hyperbola hyper) { List <Point2D> list = new List <Point2D>(); int x = hyper.a; int y = 0; int a = hyper.a; int b = hyper.b; int a2 = a * a; int b2 = b * b; long p = 2 * a2 - 2 * a * b2 - b2; int xprev = x; int yprev = y; // First Half while (Math.Abs(x * b2) >= Math.Abs(y * a2) && x <= hyper.limit) { if (hyper.orientation == Orientation.Horizontal) { list.Add(new Point2D(x, y)); } else { list.Add(new Point2D(-y, x)); } xprev = x; yprev = y; if (p > 0) { p += 2 * a2 * (2 * y + 3) - 2 * b2 * (2 * x + 2); x += 1; } else { p += 2 * a2 * (2 * y + 3); } y += 1; } // Second Half x = xprev; y = yprev; p = 2 * b2 * (x + 1) * (x + 1) - 2 * a2 * (y * y + y) - a2 * (2 * b2 + 1); while (x <= hyper.limit) { if (hyper.orientation == Orientation.Horizontal) { list.Add(new Point2D(x, y)); } else { list.Add(new Point2D(-y, x)); } if (p > 0) { p += 2 * b2 * (2 * x + 3) - 2 * a2 * (2 * y + 2); y += 1; } else { p += 2 * b2 * (2 * x + 3); } x += 1; } return(Generate4SymmetricPoint2D(list, hyper.center)); }
protected abstract List <Point2D> GeneratePoint2DList(Hyperbola hyper);
protected override List <Point2D> GeneratePoint2DList(Hyperbola hyper) { throw new NotImplementedException(); }