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

Hyperplane<double,3> intersection

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

Hyperplane<double,3> intersection

Fri Jan 13, 2012 12:04 pm
Hi, I'm asking why I can't compute a Hyperplane<double,3> intersection
Code: Select all
Hyperplane<double,3> plane1,plane2;
// initialization
plane1.intersection(plane2);


in this case the intersection should be a Vector3d.

This is possible only when the ambient dimension is 2, i.e. when the hyperplanes in ambient dimension 2 are actually lines.

I think that something similar would suffice in this case:

Code: Select all
Vector3d getPlaneIntersection( const Hyperplane<double,3> &plane1, const Hyperplane<double,3> &plane2, double lambda)
{
   double dot = plane1.normal().dot(plane2.normal());
   Vector3d cross = plane1.normal().cross(plane2.normal());
   double c1 = (plane1.offset() - plane2.offset()*dot )/(1.0-dot*dot);
   
   double c2 = (plane2.offset() - plane1.offset()*dot )/(1.0-dot*dot);

   Vector3d r = (c1*plane1.normal() + c2*plane2.normal() ) + lambda*(cross);

   return r;
}



obviously here I treat only the three-dimensional case, but this can be extended by "templatizing" the function.

(I simply implemented this wikipedia page equation: http://en.wikipedia.org/wiki/Plane_(geometry)#Line_of_intersection_between_two_planes


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]