Skip to Content.
Sympa Menu

cgal-discuss - RE: AW: [cgal-discuss] shortest line between two lines in 3d

Subject: CGAL users discussion list

List archive

RE: AW: [cgal-discuss] shortest line between two lines in 3d


Chronological Thread 
  • From: "Vu, Khuong" <>
  • To: "" <>
  • Subject: RE: AW: [cgal-discuss] shortest line between two lines in 3d
  • Date: Mon, 14 Jun 2010 12:02:05 -0500
  • Accept-language: en-US
  • Acceptlanguage: en-US

That's nice :).

Khuong
________________________________________
From: clemen
[]
Sent: Monday, June 14, 2010 8:23 AM
To:

Subject: Re: AW: [cgal-discuss] shortest line between two lines in 3d

Ok, thanks again. it turned out that khuong's way is pretty straightforward
to implement in cgal:

// get plane p1 that contains l1 and is parallel to l2
Plane_3 p1( l1, l1.point(0) + l2.to_vector() );

// get plane p2 that contains l1 and is perpendicular to p1
Plane_3 p2( l1, l1.point(0) + p1.orthogonal_vector() );

// get intersection i1 between p2 and l2
Point_3 i1;
CGAL::Object result = CGAL::intersection( p2, l2 );
if( !assign( i1, result ) ) {
Line_3 il;
if( assign( il, result ) )
std::cout << "intersection between plane and line is a line
--> l1 and l2
are parallel!" << std::endl;
return -1.0;
}

// get intersection i2 on l1
Point_3 i2 = l1.projection( i1 );

// final point is (i1+i2)/2
Point_3 f((i1.x() + i2.x()) / 2.0, (i1.y() + i2.y()) / 2.0, (i1.z() +
i2.z()) / 2.0);

--
View this message in context:
http://cgal-discuss.949826.n4.nabble.com/shortest-line-between-two-lines-in-3d-tp2251943p2254338.html
Sent from the cgal-discuss mailing list archive at Nabble.com.

--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://lists-sop.inria.fr/wws/info/cgal-discuss




Archive powered by MHonArc 2.6.16.

Top of Page