Project point on a line

Please help solving this geometric problem.

Given a Dynamo point project it on a Dynamo line. Obtain projected point.

There is a lot of nodes dealing with projecting point on a surface, but not dealing with projecting point on a line.

Theres a built in node that reports the distance to geometry, so I used it to obtain the shortest distance, then made a sphere and intersected it with the line. Alas, the rounding makes this method non-reliable, one of my intersection points turned up as a line with a length of 0,005 millimeter.

Please help.

Michail,

Can you demonstrate your exact problem? Sample files, steps taken, images are all accepted and even welcome. Please have a look at this post: POST It might be from a different forum, but I have been stressing to everyone that they need to ask better questions.

Thank you,

You want to obtain the point on a line that is closest to some other point?

I think all you need is Geometry.ClosestPoint

2 Likes

Thanks for the replies guys. I am sorry, I thought my explanation was complete.

Anyway, I didn’t know that Dynamo has extensive vector manipulation node library. Now I know and I solved the problem by using vector calculation of a point projection on a line:

<a href="http://gamedev.stackexchange.com/questions/72528/how-can-i-project-a-3d-point-onto-a-3d-line"><span class="pln" style="color: #000000">A </span><span class="pun" style="color: #000000">+</span><span class="pln" style="color: #000000"> dot</span><span class="pun" style="color: #000000">(</span><span class="pln" style="color: #000000">AP</span><span class="pun" style="color: #000000">,</span><span class="pln" style="color: #000000">AB</span><span class="pun" style="color: #000000">)</span><span class="pun" style="color: #000000">/</span><span class="pln" style="color: #000000"> dot</span><span class="pun" style="color: #000000">(</span><span class="pln" style="color: #000000">AB</span><span class="pun" style="color: #000000">,</span><span class="pln" style="color: #000000">AB</span><span class="pun" style="color: #000000">)</span><span class="pun" style="color: #000000">*</span></a><span class="pln" style="color: #000000"><a href="http://gamedev.stackexchange.com/questions/72528/how-can-i-project-a-3d-point-onto-a-3d-line"> AB = P'

</a><img src="http://dynamobim.org/wp-content/uploads/forum-assets/mgodamgaard-ri-dk/01/18/PointProjectionOnLine.png" alt="PointProjectionOnLine" width="1451" height="577" />


</span>

Michail,

Hahaha, it always amazes me how every person learns differently. I love the mathematical approach. Well done!

The same in crude python:

The same using list comprehension:

Where is the line?.. If you want to project a point onto a line use Vikram’s solution, if you want to project a vector onto a vector then your solution is fine.

Yes, it is actually a solution to project a point onto a line between two other points. So if you have a line to begin with, you have to extract two points from it. End and start points work fine. :slight_smile:

Hahaha, sorry. I think you only had a bunch op points… no lines. So it’s even easier… Geometry.ClosestPointTo works fine, and here other solution. http://i64.tinypic.com/sm94jk.png

Thanks for those, will try them out