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

confused with parameterized line intersection

Tags: None
(comma "," separated)
thelorax
Registered Member
Posts
3
Karma
0
OS
Code: Select all
  ParametrizedLine<double, 2> line1;
  Hyperplane<double, 2> line2;
  line1 = ParametrizedLine<double, 2>::Through(Vector2d(-1,0), Vector2d(-0.5,0.0));
  line2 = Hyperplane<double, 2>::Through(Vector2d(0,1), Vector2d(0,-1));

  double inter = line1.intersection(line2);
  cout<<"inter: "<<inter<<endl;


the print there is printing 1 for me. exactly 1.
I was expecting some thing either greater than 1 or less than 0, since those lines don't intersect.
I'm using eigen 2.0.10 with gcc 4.3.4

thanks.
User avatar
bjacob
Registered Member
Posts
658
Karma
3
line1 is horizontal, line2 is vertical, so they do intersect. "Through" means that you're defining a line by giving 2 points through which it passes.


Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list!
thelorax
Registered Member
Posts
3
Karma
0
OS
Ok, so I made some progress, but I just want to make sure I understand what's going on...

Code: Select all
  ParametrizedLine<double, 2> line1(Vector2d(-1.0,0.0), Vector2d(0.5,0.0));
  Hyperplane<double, 2> line2;
  line2 = Hyperplane<double, 2>::Through(Vector2d(0.0,1.0), Vector2d(0.0,-1.0));

  double inter = line1.intersection(line2);
  cout<<"inter: "<<inter<<endl;


that is the same code as before, but this time instead of using the "Through" function to create the ParameterizedLine I used the origin and direction constructor. the output from that code is 2, which makes sense to me because -1+2*0.5 = 0.
Here is what I don't get: the line1 variable in both the bit of code I posted represent the same line, so why is the result of the intersection different? Is it because I didn't specify a direction in the first one that it only returns 1 to say "they do intersect at some point". If so I find it very confusing, if the user passes in a line with created with Through then the code in a library may expect a line with a specific direction and length so the intersection function works a certain way.
User avatar
bjacob
Registered Member
Posts
658
Karma
3
Ok so now you are using the ParametrizedLine constructor taking a point and a direction vector. But that constructor assumes the direction vector to be normalized, as is explained in the documentation,
http://eigen.tuxfamily.org/dox/classEig ... 19ea17074f

So your first line is faulty, as (-0.5,0) is not a normalized vector.

I don't understand the rest of your questions. ParametrizedLine is a class representing a parametrized line, that is the data of a origin point and a direction unit vector. It offers a static method Through() constructing such a ParametrizedLine from the data of two points through which the line must pass. But that is still the same ParametrizedLine type.


Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list!
thelorax
Registered Member
Posts
3
Karma
0
OS
ok, I missed the part about the normalization. intersection tests are as expected now.

thank you.


Bookmarks



Who is online

Registered users: abc72656, Bing [Bot], daret, Google [Bot], Sogou [Bot], Yahoo [Bot]