[Interest] Distance from point to path.

Nye kshegunov at gmail.com
Tue Dec 29 07:42:53 CET 2015


Hello,
What kind of primitives do you have in your path, lines? If so, you could
"parse" the path by elements and get the normal vectors for each one line,
and check if they (could) pass through your point and at what distance the
point is. If you have curves that might be quite more involved. Is your
path closed? You could also take a circle centered on your point with some
radius, and get the two intersection points (the circle chord) get the
normal vector from that chord. The normal vector will give you a direction
for "probing" for intersection with the path, but it still might need a few
iterations to find the shortest distance to the path, as you'll need to
ensure that the "probing vector" is perpendicular to the path curve.

Kind regards,
Konstantin.

On Mon, Dec 28, 2015 at 11:49 PM, william.crocker at analog.com <
william.crocker at analog.com> wrote:

> Hello:
>
> Given a QPoint and a QPainterPath.
> How do I find the distance from the QPoint to the
> closest point along the QPainterPath.
>
> I could step along the path with pointAtPercent
> looking for the closest point, but that seems unduly
> expensive: O(100N).
>
> Any better ideas.
>
> Thanks.
>
> Bill
>
> ---------
> All of the above to find the shape closest to a mouse click.
> Note that methods are provided to find the set of objects
> which intersect a rectangle centered on the point, but which one
> is really the closest?
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20151229/9a385997/attachment.html>


More information about the Interest mailing list