This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Plane and lines intersections

Tags: None
(comma "," separated)
linello
Registered Member
Posts
56
Karma
0
OS

Plane and lines intersections

Wed Apr 20, 2011 1:52 pm
Hi,

I'm wondering how to compute the intersection of a plane with a line in a simple way...

Code: Select all
double focalDistance = -418.5;
Vector3d p1(0,0,focalDistance);
Vector3d p2(1,0,focalDistance);
Vector3d p3(0,1,focalDistance);

// Here is my plane, it passes through 3 points
Hyperplane<double,3> focalPlane = Hyperplane<double,3>::Through( p1,p2,p3 );

// Now I want to define a line through 2 points
Hyperplane<double,3> line = Hyperplane<double,3>::Through( p1,p2 );

// but now the intersection method gives me strange asserts:
Vector3d intersectionPoint = focalPlane.intersection( line );


In file included from ../eigen/Eigen/Geometry:47,
from test.cpp:34:
../eigen/Eigen/src/Geometry/Hyperplane.h: In member function ‘Eigen::Matrix<_Scalar, AmbientDimAtCompileTime, 1, ((Eigen::._90)0u | (((AmbientDimAtCompileTime == 1) && (1 != 1)) ? (Eigen::._90)1u : (((1 == 1) && (AmbientDimAtCompileTime != 1)) ? (Eigen::._90)0u : (Eigen::._90)0u))), AmbientDimAtCompileTime, 1> Eigen::Hyperplane<_Scalar, _AmbientDim, Options>::intersection(const Eigen::Hyperplane<_Scalar, _AmbientDim, Options>&) [with _Scalar = double, int _AmbientDim = 3, int _Options = 0]’:
test.cpp:377: instantiated from here
../eigen/Eigen/src/Geometry/Hyperplane.h:194: error: ‘THIS_METHOD_IS_ONLY_FOR_VECTORS_OF_A_SPECIFIC_SIZE’ is not a member of ‘Eigen::internal::static_assertion<false>’
make: *** [test.o] Error 1


I don't understand why: THIS_METHOD_IS_ONLY_FOR_VECTORS_OF_A_SPECIFIC_SIZE

How should I compute the intersection of a plane with a line?

Documentation here has no examples...

Thanks!
User avatar
bjacob
Registered Member
Posts
658
Karma
3

Re: Plane and lines intersections

Wed Apr 20, 2011 1:59 pm
In 3D space, a hyperplane is a 2D plane. Lines are not hyperplanes in 3D space. Therefore Hyperplane<double,3> can't represent a line.

Suggestion: use the ParametrizedLine class instead to represent your line.


Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list!
linello
Registered Member
Posts
56
Karma
0
OS

Re: Plane and lines intersections

Wed Apr 20, 2011 2:36 pm
Ok, thanks for the suggestion, but I also have such problem.


Code: Select all
Vector3d n1(0,0,0);
Vector3d n2(0,1,1);

// I initialize the line with two points passing through it
ParametrizedLine<double,3> pline = ParametrizedLine<double,3>::Through(n1,n2);


// So if I'm correct this is the t at which pline intersect the last plane "focalPlane"   
double intersection = pline.intersection( focalPlane ) ;

// Now, how to compute the coordinates of such intersection? I think this is the correct way...

cerr << intersection*((n2-n1).normalized()) + n1  << endl;


Last edited by linello on Thu Apr 21, 2011 6:42 am, edited 1 time in total.
User avatar
bjacob
Registered Member
Posts
658
Karma
3
Yeah, I think that's it... and sorry for the clumsy API, I didn't remember that it returned the parameter. We need a method returning the point itself.


Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list!


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Evergrowing, Google [Bot], q.ignora