A Fast Bresenham Type Algorithm For Drawing Ellipse
-
I read "A Fast Bresenham Type Algorithm For Drawing Ellipse" by John Kennedy Mathematics Department. Below function was developed base on above algorithm. I want to ask someone help me, how can develop below function to rotate ellipse. If someone have an other ideals, can you help me!
void CBGraphics::DrawEllipse(HDC hDC, int x1, int y1, int x2, int y2, COLORREF color) { long x, y, XChange, YChange, EllipseError, TwoASquare, TwoBSquare, StoppingX, StoppingY; TwoASquare = 2 * x2 * x2; TwoBSquare = 2 * y2 * y2; x = x2; y = 0; XChange = y2 * y2 * (1 - 2 * x2); YChange = x2 * x2; EllipseError = 0; StoppingX = TwoBSquare * x2; StoppingY = 0; while( StoppingX >= StoppingY) { Put4Pixel(hDC, x1, y1, x, y, color); y++; StoppingY += TwoASquare; EllipseError += YChange; YChange += TwoASquare; if( ( 2 * EllipseError + XChange) > 0 ) { x--; StoppingX -= TwoBSquare; EllipseError += XChange; XChange += TwoBSquare; } } x = 0; y = y2; XChange = y2 * y2; YChange = x2 * x2 * (1 - 2 * y2); EllipseError = 0; StoppingX = 0; StoppingY = TwoASquare * y2; while (StoppingX <= StoppingY) { Put4Pixel(hDC, x1, y1, x, y, color); x++; StoppingX += TwoBSquare; EllipseError += XChange; XChange += TwoBSquare; if( (2 * EllipseError + YChange) > 0) { y--; StoppingY -= TwoASquare; EllipseError += YChange; YChange += TwoASquare; } } }
-
I read "A Fast Bresenham Type Algorithm For Drawing Ellipse" by John Kennedy Mathematics Department. Below function was developed base on above algorithm. I want to ask someone help me, how can develop below function to rotate ellipse. If someone have an other ideals, can you help me!
void CBGraphics::DrawEllipse(HDC hDC, int x1, int y1, int x2, int y2, COLORREF color) { long x, y, XChange, YChange, EllipseError, TwoASquare, TwoBSquare, StoppingX, StoppingY; TwoASquare = 2 * x2 * x2; TwoBSquare = 2 * y2 * y2; x = x2; y = 0; XChange = y2 * y2 * (1 - 2 * x2); YChange = x2 * x2; EllipseError = 0; StoppingX = TwoBSquare * x2; StoppingY = 0; while( StoppingX >= StoppingY) { Put4Pixel(hDC, x1, y1, x, y, color); y++; StoppingY += TwoASquare; EllipseError += YChange; YChange += TwoASquare; if( ( 2 * EllipseError + XChange) > 0 ) { x--; StoppingX -= TwoBSquare; EllipseError += XChange; XChange += TwoBSquare; } } x = 0; y = y2; XChange = y2 * y2; YChange = x2 * x2 * (1 - 2 * y2); EllipseError = 0; StoppingX = 0; StoppingY = TwoASquare * y2; while (StoppingX <= StoppingY) { Put4Pixel(hDC, x1, y1, x, y, color); x++; StoppingX += TwoBSquare; EllipseError += XChange; XChange += TwoBSquare; if( (2 * EllipseError + YChange) > 0) { y--; StoppingY -= TwoASquare; EllipseError += YChange; YChange += TwoASquare; } } }
Hi, This Algorithm is based on 4 point symmetry of ellipse. And when the ellipse is rotated this symmetry will lost at numerous position. This algorithm can be used to increase the speed of plotting ellipse in a raster system for ellipse in its symmetric shape. The parameters to the function is center and X and Y radius. I strongly think this algorithm cannot be used for plotting ellipse in all ellipse transformation.
-
Hi, This Algorithm is based on 4 point symmetry of ellipse. And when the ellipse is rotated this symmetry will lost at numerous position. This algorithm can be used to increase the speed of plotting ellipse in a raster system for ellipse in its symmetric shape. The parameters to the function is center and X and Y radius. I strongly think this algorithm cannot be used for plotting ellipse in all ellipse transformation.