Find (3d point) intersection of 2 lines?
-
I can't find via search if this has been answered before.
- 2 lines including each of their end point coordinates are known,
they also intersect and share a common plane. - The common plane these 2 lines intersect on may be xy, yz or xz planes
- Since the end points of each line may change their common intersection point will also change.
How do I quickly derive the intersecting point, for any varying 2 line intersection?
TIA!
- 2 lines including each of their end point coordinates are known,
-
Try
point = Geom.intersect_line_line(edge1.line, edge2.line)
You either get a
point
ornil
if the two 'lines' don't intersect.
Unlike an 'edge', a 'line' is infinite, so two 'edges' might not physically intersect even though their 'lines' do.
If you get a point you can then test if it actually falls on an end point of an edge
point == edge1.start.position point == edge2.end.position point == edge1.start.position point == edge2.end.position
wheretrue
shows it is at a vertex
AND if the point falls between the start/end of each edge, the test is...
point.vector_to(edge1.start.position) == point.vector_to(edge1.end.position) point.vector_to(edge2.start.position) == point.vector_to(edge2.end.position)
Note that gettingtrue
means that the point is not physically on the edge because the vectors are both in the same direction, andfalse
means that the point is on the edge and between the start/end...
Advertisement