Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. A Fast Bresenham Type Algorithm For Drawing Ellipse

A Fast Bresenham Type Algorithm For Drawing Ellipse

Scheduled Pinned Locked Moved C / C++ / MFC
graphicsalgorithmshelp
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    KienNT78
    wrote on last edited by
    #1

    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; } } }

    R 1 Reply Last reply
    0
    • K KienNT78

      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; } } }

      R Offline
      R Offline
      Rajkumar R
      wrote on last edited by
      #2

      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.

      K 1 Reply Last reply
      0
      • R Rajkumar R

        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.

        K Offline
        K Offline
        KienNT78
        wrote on last edited by
        #3

        Thanks you for your advice. by the way, Can you give me an other algorithm that you think it's suit to solve my trouble? ;)

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups