On 23/06/2015 at 17:25, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 16
Platform: Windows ;
Language(s) : C++ ;
---------
Hello, I've written a function to test if two edges are on the same plane. For example the edges
P1 (0;300;0)
Q1 (0;300;30)
P2 (0;300;30)
Q2 (400;300;30)
are on the Y-Plane.
But my function doesn't work and I don't know why.
Int32 GetEdgesPlane (Vector64 p1, Vector64 q1, Vector64 p2, Vector64 q2) {
// return 1 for X, 2 for Y, 3 for Z and 0 if not on a Plane
GePrint(String::VectorToString(p1)+String::VectorToString(q1)+String::VectorToString(p2)+String::VectorToString(q2));
if (CompareFloatTolerant(p1.x,q1.x) && CompareFloatTolerant(q1.x,p2.x) && CompareFloatTolerant(p2.x,q2.x)) {
return 1;
} else if (CompareFloatTolerant(p1.y,q1.y) && CompareFloatTolerant(q1.y,p2.y) && CompareFloatTolerant(p2.y,q2.y)) {
return 2;
} else if (CompareFloatTolerant(p1.z,q1.z) && CompareFloatTolerant(q1.z,p2.z) && CompareFloatTolerant(p2.z,q2.z)) {
return 3;
} else {
return 0;
}
}
And here is a piece of my console output:
(0;300;0)(0;300;30)(0;300;0)(0;300;30)
1
(0;300;0)(0;300;30)(0;300;30)(400;300;30)
0
(0;300;0)(0;300;30)(400;300;30)(400;300;0)
0
(0;300;0)(0;300;30)(400;300;0)(0;300;0)
2
(0;300;0)(0;300;30)(370;300;30)(400;300;30)
0
(0;300;0)(0;300;30)(400;300;30)(400;300;-370)
0
(0;300;0)(0;300;30)(400;300;-370)(370;300;-370)
0
(0;300;0)(0;300;30)(370;300;-370)(370;300;30)
0
(0;300;30)(400;300;30)(0;300;0)(0;300;30)
0
(0;300;30)(400;300;30)(0;300;30)(400;300;30)
0
(0;300;30)(400;300;30)(400;300;30)(400;300;0)
0
(0;300;30)(400;300;30)(400;300;0)(0;300;0)
0
(0;300;30)(400;300;30)(370;300;30)(400;300;30)
0
(0;300;30)(400;300;30)(400;300;30)(400;300;-370)
0
(0;300;30)(400;300;30)(400;300;-370)(370;300;-370)
0
As you can see, sometimes it works but the most time not. Can someone help?
Thanks
crush4