$include_dir="/home/hyper-archives/geometry/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [geometry] intersection for two segments in 3D failed
From: Adam Wulkiewicz (adam.wulkiewicz_at_[hidden])
Date: 2015-03-24 09:59:12
Hi,
Hmfkz wrote:
> Hi,
>
> I tried to use boost geometry for intersection of the two line segments in
> 3D.
> Here
> <http://stackoverflow.com/questions/29118583/boost-intersection-two-line-segments-in-3d/29123979?noredirect=1#comment46474484_29123979>
> is the link of question in stackoverflow.
>
> I am wondering if it is possible to do intersection for segments in 3D. if
> so, will you please help me through that.
>
> I am using boost version 1.53.
>
Sorry, 3D intersection is not yet properly supported. I think it works 
properly only with segments containing points with z coordinate equal to 0.
But yes, in the case of Linear/Linear geometries combinations (e.g. 
Segment/Segment, Linestring/Linestring, etc.) it should be possible to 
calculate the intersection in pure 3D cartesian. Linear/Areal (e.g. 
Linestring/Polygon) would probably be more complicated since for each 
Polygon we'd need to calculate sides (that's an implementation detail) 
WRT the Polygon's surface.
Could you please fill a ticket with the feature request here 
https://svn.boost.org/trac/boost/newticket so we won't forget about it?
But do you really need to find an intersection of segments in 3D? Are 
those segments arbitrary distributed in 3D or are they e.g. lying on 
some plane? If the latter was true, you could first project those 
segments into the plane and then find the intersection of 2d segments.
In the case of "true" 3d cartesian segment/segment you could try to 
implement it by yourself.
E.g. see: http://www.realtimerendering.com/intersections.html (ray/ray 
case).
Here is a formula: http://www.realtimerendering.com/intersections.html#I304
where
o1 = segment1.p1
d1 = normalized(segment1.p2 - segment1.p1)
o2 = segment2.p1
d2 = normalized(segment2.p2 - segment2.p1)
(o states for ray's "origin", d for "direction")
And there are some special cases which must be handled like parallel 
rays or closest points outside a segment (t < 0 || t > length(segment)).
Regards,
Adam