Results 1 to 7 of 7

Thread: drawing clothoid segments

  1. #1
    Join Date
    Jul 2011
    Posts
    16
    Qt products
    Qt4
    Platforms
    Windows

    Default drawing clothoid segments

    Hi,

    I am trying to create an application which the user can use to graphically draw clothoid (Euler spiral) segments, i.e. the user should be able to shape the curve only by using the mouse.

    But I am at loss at to which drawing method I should use. I thought of drawing them as Bezier curves but the data is not compatible. How can I paint in Qt curves with specific data, such as curvatures and arc length?

    Thanks in advance.

  2. #2
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: drawing clothoid segments

    You have to map your plotting onto the existing Qt (or OpenGL) graphics primitives. The only available mapping I can see is to individual points or line segments; in other words, you'll have to plot the curves yourself. I could be wrong; there may be a way to express these curves or approximate them using Bezier representation, but if there is it isn't apparent in the short time I spent looking at the math.

    The math for calculating the plot doesn't seem terribly complicated, so doing this in "real time" isn't likely to cause any problems. If the processor starts to bog down, you could adopt a method using successive refinement, beginning with a fairly wide plotting interval and polishing at pixel resolution when the low-res version is done or the mouse stops moving.

  3. #3
    Join Date
    Jul 2011
    Posts
    16
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: drawing clothoid segments

    Is there an example code which I could run? For the curve plotting I mean.

  4. #4
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: drawing clothoid segments

    Quote Originally Posted by schmimona View Post
    Is there an example code which I could run? For the curve plotting I mean.
    I haven't looked. The math is described on Wikipedia and several other places.

  5. #5
    Join Date
    Jul 2011
    Posts
    16
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: drawing clothoid segments

    When you were saying plotting curves myself did you have some method in mind? Or were you referring to the QWT library?

  6. #6
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: drawing clothoid segments

    Either way. You can plot points (or, more likely, line segments) in QPainter, or you can embed a Qwt plot in your UI.

  7. #7
    Join Date
    Jan 2009
    Location
    Germany
    Posts
    387
    Thanks
    101
    Thanked 15 Times in 15 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: drawing clothoid segments

    Parameterize your clothoid curve such that you can obtain the x(t) and y(t) coordinates for a parameter t in [0:1] where 0 is the starting point and the 1 is the last point of your curve. Then you can simply draw your curve in the paint event of a widget like this:

    Qt Code:
    1. void SimpleExampleWidget::paintEvent(QPaintEvent *)
    2. {
    3. QPainter painter(this);
    4. painter.setPen(Qt::blue);
    5.  
    6. for (double t = 0; t <= 1; t = t+0.01)
    7. painter.drawLine(QLineF(x(t), y(t), x(t+0.01), y(t+0.01));
    8. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Drawing multiple line segments
    By twells5 in forum Qt Programming
    Replies: 8
    Last Post: 3rd June 2011, 14:23
  2. Qt Drawing
    By Talguy in forum Newbie
    Replies: 4
    Last Post: 12th January 2011, 04:14
  3. Help drawing a gui
    By franco.amato in forum Qt Programming
    Replies: 16
    Last Post: 7th October 2010, 11:26
  4. Replies: 1
    Last Post: 6th May 2009, 15:29
  5. Drawing an arc.
    By munna in forum Qt Programming
    Replies: 6
    Last Post: 13th June 2006, 05:36

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.