How to draw clothoids graphically in Qt?

2019-01-25 21:40发布

I am trying to build an application which the user can use to draw clothoids with the mouse, i.e. to set the start point and the end point of the spiral and then by dragging these points with the mouse he could also set the shape of the clothoid by modifying the start and end curvature. Probably for changing the curvature I will need to use the tangents though I am not sure of that.

How can one implement that in Qt? Do you know of any example codes that I could run in Qt?

标签: c++ math qt4
2条回答
2楼-- · 2019-01-25 22:11

I realize that this is an old question, but for interested parties there is a good discussion of theory and pseudocode for Euler spirals (clothoids) in the paper "Euler Spiral for Shape Completion" by Kimia, Frankel, and Popescu. Sample C++ code can be found online at Brown University's website.

Euler Spiral for Shape Completion

Page with download link for C++ code for method of Kimia, Frankel, and Popescu

Papers by Levien and others suggest methods to improved upon the "biarc" calculation of the paper by Kimia, et al. Levien's paper includes an in-depth history.

The Euler spiral: a mathematical history by Raph Levien

You only need four parameters to draw the spiral: two end points, and the angles of tangents at those end points. (You don't need to define curvature.) The code outputs the intermediate points between the two end points at distance increments of your choice. You simply need to plot and connect those intermediate points.

Once you implement the code, you may need to tweak some of the parameters such as the minimum curvature. You'll likely see a few parameters for which the code "blows up".

查看更多
forever°为你锁心
3楼-- · 2019-01-25 22:12

The best approach would probably be to use the Graphics View Framework.

There are a few examples that should help you getting started in the Graphics View Examples page. The Diagram scene one looks like a good starting point for what you want to achieve.

查看更多
登录 后发表回答