Results 1 to 2 of 2

Thread: Cubic Bezier approximation using circular arcs and lines

  1. #1
    Join Date
    Jul 2016
    Posts
    1
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Cubic Bezier approximation using circular arcs and lines

    Hi,

    I'm working on a project where the program generate the QPainterPaths, later this path will be converted to GRBL commands and fed to the CNC machines.
    I see from the QPainterPath source most of the paths of arcs, ellipse and curve are converted/drawn using cubic bezier curve by calling cubicTo.
    Unfortunately GRBL provides commands for only arcs and lines.

    So the bezier curve need to be converted/approximated in to set of arcs and lines before the bezier curve can be drawn by the machine.
    So can someone please let me know how this can be achieved in Qt?

    what I'm tying to achive is same as mentioned in these document.

    Cubic bezier approximation
    http://ac.els-cdn.com/S0377042796000...15fa82b6afe5bc

    Quadratic bezier approximation
    http://ac.els-cdn.com/03770427949039...642e0e264dd6c7

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,325
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows
    Thanked 879 Times in 827 Posts

    Default Re: Cubic Bezier approximation using circular arcs and lines

    One option is to use QPainterPath::toSubpathPolygons(), but the implemented subdivision is tailored for rendering to screen, what means it terminates for a "flatness" value of 0.5 ( going deeper doesn't make sense, when everything is rounded to 1 pixel later ).

    If you need something more flexible you could have a look at https://sourceforge.net/p/qwt/code/H...qwt_spline.cpp. QwtSplineBezier::toPolygon() offers an implementation depending on a flatness parameter, one you can set on application side. The implementation is based on "Piecewise Linear Approximation of Bézier Curves" by Roger Willcocks ( http://www.rops.org ).

    Uwe

Similar Threads

  1. Selection of Cubic QPainterPath
    By veiovis in forum Qt Programming
    Replies: 7
    Last Post: 5th July 2015, 23:53
  2. around circular dependencies
    By tonnot in forum General Programming
    Replies: 6
    Last Post: 18th February 2011, 13:20
  3. Circular Layout
    By Leolander in forum Qt Programming
    Replies: 1
    Last Post: 30th March 2010, 09:02
  4. Circular QLinkedList
    By dyngoman in forum Qt Programming
    Replies: 1
    Last Post: 24th March 2010, 09:57
  5. opengl bezier surface
    By zorro68 in forum Qt Programming
    Replies: 6
    Last Post: 22nd February 2007, 18:44

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.