A Funny C++ Bug
I wrote a piece of code for calculating the intersection between two planes. Here are my code:
//cout << "x=" << x << " y=" << y << endl;
Here is the driven code:
The problem is:
when I comment the line " cout << "x=" << x << " y=" << y << endl;" out, the result is:
0 0 0
-4.94321e-37 -1 8.38816e-38
which is wrong.
But if I leave the line uncommented, the result is :
0 0 0
1 -1.52385e-314 0
which is correct, the intersection line normal direction is X axis.
Can anyone tell me how to solve the problem please?
My compiler is GNU C++ 4.1.2
Not an answer to your question, but (if the code you presented is the code you actually use) the denominator in your equation for y appears to be incorrect.
Also, when you calculate the cross product, you seem to be using GetNormal both as a function in the "plane" class and as a stand-alone function. Is it really defined that way?
Thanks for your reply. The denominator for y is a typing error, and it's not the problem.
The GetNormal() is a function in the ML_Plane Class, and it can be considered as:
Cross(this->GetNormal(), plane.GetNormal() );
Note that the signature of the function is :
bool ML_Plane::IntersectionPlane(ML_Plane& plane, ML_Line& line);
I have tried many different ways but the problem is still there.
Could this be the problem of the compiler's optimization problem?
is p0 set up?
Also what does GetNormal() return?
a1 = GetNormal(); an array?
GetNormal() * (*p0); a scalar?
|All times are GMT -5. The time now is 02:19 AM.|