calculating the projection of a point on a line

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

calculating the projection of a point on a line

Jeremy Murphy
Dear Geometers,

I have looked, but I cannot find an algorithm (in BG) to calculate the projection of a point on a line, as per the explanation here: http://cs.nyu.edu/~yap/classes/visual/03s/hw/h2/math.pdf

Have I simply missed it or is there a simple combination of algorithms to calculate it?

So far I have been rolling my own linear algebra computation as per that paper, but I was hoping to simplify the code and use something built in.

Thanks, cheers.

Jeremy


_______________________________________________
Geometry mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/geometry
Reply | Threaded
Open this post in threaded view
|

Re: calculating the projection of a point on a line

sonic
Hi Jeremy, 

You should look at some basic linear algebra. There are a number of ways to derive the formula and each source covers this from a slightly different angle (no pun intended :)); try to understand geometric meaning of the line equation (of the form a*t + b) and the dot product (a dot b). Drop me an email if you are struggling with this.

Greets,
mike

On 2 August 2016 at 08:27, Jeremy Murphy <[hidden email]> wrote:
Dear Geometers,

I have looked, but I cannot find an algorithm (in BG) to calculate the projection of a point on a line, as per the explanation here: http://cs.nyu.edu/~yap/classes/visual/03s/hw/h2/math.pdf

Have I simply missed it or is there a simple combination of algorithms to calculate it?

So far I have been rolling my own linear algebra computation as per that paper, but I was hoping to simplify the code and use something built in.

Thanks, cheers.

Jeremy


_______________________________________________
Geometry mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/geometry



_______________________________________________
Geometry mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/geometry
Reply | Threaded
Open this post in threaded view
|

Re: calculating the projection of a point on a line

Adam Wulkiewicz
In reply to this post by Jeremy Murphy
Hi Jeremy,

Jeremy Murphy wrote:
Dear Geometers,

I have looked, but I cannot find an algorithm (in BG) to calculate the projection of a point on a line, as per the explanation here: http://cs.nyu.edu/~yap/classes/visual/03s/hw/h2/math.pdf

Have I simply missed it or is there a simple combination of algorithms to calculate it?

So far I have been rolling my own linear algebra computation as per that paper, but I was hoping to simplify the code and use something built in.

There is no such algorithm in BG.

There are however tools allowing to do basic linear algebra computation (using points as vectors). Actually what you'd like to do is implemented as a part of projected_point distance strategy:

https://github.com/boostorg/geometry/blob/develop/include/boost/geometry/strategies/cartesian/distance_projected_point.hpp#L119

This strategy calculates the distance between a point and its projection into a segment. So you could extract a part of the code from there.

You could also try to use Boost.QVM library newly added to Boost.

Regards,
Adam

_______________________________________________
Geometry mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/geometry