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

Hyperplane strange behaviour

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

Hyperplane strange behaviour

Mon Feb 14, 2011 12:00 pm
Hi you all, I noticed something strange with the behaviour of Hyperplane class.

Starting from 3 points I create an hyperplane with the Through method, then I create other 3 points from the initial points but rotated 45° w.r.t z-axis.


I then create another Hyperplane from these 3 rotated points.
The strange thing is that the normals are the same? How is it possible?

Code: Select all
// This is the rotation matrix of 90° degrees around Z axis
Matrix3d R = AngleAxis<double>(M_PI/2.0,Vector3d(0,0,1)).toRotationMatrix();

// Here I declare two set of points lying on two different planes
vector<Vector3d> plane1(3),plane2(3);

// this plane's normal should be (0,0,1)
plane1[0]= Vector3d(-1,1,0);
plane1[1]= Vector3d(1,1,0);
plane1[2]= Vector3d(1,-1,0);

// This is the rotated set, it's normal should be (1,0,0) because of the rotation
        for (int i=0; i<3; i++)
                plane2[i]=R*plane1[i];          
   
   cerr << "PLANE 1" << endl;
   for (int i=0; i<3; i++)
                cerr << plane1[i].transpose() << endl;
   
   cerr << "PLANE 2" << endl;
   for (int i=0; i<3; i++)
                cerr << plane2[i].transpose() << endl;
   
   // Here I build the two 2-dimensional planes
   Hyperplane<double,3> h1,h2;
   h1 = Hyperplane<double,3>::Through( plane1[0],plane1[1],plane1[2] );
   h2 = Hyperplane<double,3>::Through( plane2[0],plane2[1],plane2[2] );
   // this method of defining from points with static Through is quite strange indeed...

   double dot = (h1.normal()).dot(h2.normal());
   double normalization = h1.normal().norm()*(h2.normal().norm());
   
   cerr << "h1 normal= " << h1.normal().normalized() << endl;
   cerr << "h2 normal= " << h2.normal().normalized() << endl;
   cerr << "Angle= " << toDegrees( acos(dot/normalization) ) << endl;


The output is the following:
Code: Select all
PLANE 1
-1 1 0
1 1 0
 1 -1  0
PLANE 2
-1 -1  0
-1 1 0
1 1 0
h1 normal= -0
0
1
h2 normal= 0
0
1
Angle= 0


but the angle is always zero because the normals to both h1 and h2 are (0,0,1)

Where am I wrong?

Something strange in the Hyperplane construction?
jitseniesen
Registered Member
Posts
204
Karma
2

Re: Hyperplane strange behaviour  Topic is solved

Mon Feb 14, 2011 12:05 pm
I don't see anything strange. The first plane you construct is the plane {z=0} (the Oxy plane) and its normal points in the z-direction. So it remains the same if you rotate it around the z-axis.


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Evergrowing, Google [Bot], ourcraft