How to find segments intersection?

Hi !

Is there any way to find an intersection between two segments ? Or rays ?
I searched the Ray doc and I found that there is methods for finding an intersecting vector with triangles, boxes, and spheres, so I am surprised to find none with segments.

Hi!
Could you explain it more detailed? What segments? Segments of what?

As “segments” I mean arrays of two vector3.

the intersecting vetor3 between [ [0,5,0], [0,-5,0] ] and [ [5,0,0], [-5,0,0 ] ] would be [0,0,0].

AFAIK, there is no such functionality “out-of-the-box” in Three.js.

Are points of those two lines (segments) always co-planar? Do those lines (segments) always intersect?

Thanks anyway,

But it is surprising, as Ray.intersectBox() can find an intersecting vector between a ray and a three-dimensional object, I’d expected that the functionality was available as well for an (a priori) simpler task (intersection between two rays). I will try to find a workaround and keep you posted.

For my use, the lines can be not-coplanar, and it should be possible to return null if there is no intersection.

Just out of curiousily, why do you want to use finding intesection between lines? What’s the task? :slight_smile:

I want to make a function to offset polylines (array of vector3) according to their bisectors.
In order to code a parametric geometry. (so the user can change the shape of the polyline, and the offset will adapt).

Could you provide an explanatory picture?

2019-02-01_171343

In blue the base polyline, in black the polyline offset from the blue according to bisectors.

Maybe this topic will be useful for you:

1 Like

Thank you, I will use that as a starting point !