the test sometimes fails even for values "much larger" than F32_ROUNDING_ERROR
pls give some numbers that fail on your side, because mine don't.
i generated 10000 points A B, all coords are 1..1000000 times ROUNDING_ERROR_f32
Code: Select all
// test
for (u32 i=0; i<10000; i++)
{
core::vector2df A( ((rand()%1000000)+1)*core::ROUNDING_ERROR_f32, ((rand()%1000000)+1)*core::ROUNDING_ERROR_f32 );
core::vector2df B( ((rand()%1000000)+1)*core::ROUNDING_ERROR_f32, ((rand()%1000000)+1)*core::ROUNDING_ERROR_f32 );
core::vector2df P = A+((B-A).normalize()*(f32)((B-A).getLength()/(f32)((rand()%1000000)+1)));
core::stringc s("");
s+=core::sprintf("A(%f,%f), B(%f,%f), P(%f,%f)\n", A.X, A.Y, B.X, B.Y, P.X, P.Y);
s+=core::sprintf("Orientation = %f", getPointOrientation(A,B,P));
s+=core::sprintf(", isBetweenPoints = %s", (isBetweenPoints(A,B,P))?"true":"false");
s+=core::sprintf(", isPointOnLine = %s\n", (isPointOnLine(A,B,P))?"true":"false");
s+=core::sprintf("Orientation2 = %f", getPointOrientation2(A,B,P));
s+=core::sprintf(", isBetweenPoints2 = %s", (isBetweenPoints2(A,B,P))?"true":"false");
ELOG_LEVEL lvlResult = (isPointOnLine2(A,B,P))?ELL_NONE:ELL_ERROR;
s+=core::sprintf(", isPointOnLine2 = %s\n", (lvlResult==ELL_NONE)?"true":"false");
logger->log( s.c_str(), lvlResult );
}
the only difference between isPointOnLine && isPointOnLine2 is core::equals(d,0.0f,1.5f*ROUNDING_ERROR_f32);
Result: All function calls to isPointOnLine failed !!!!
All function calls to isPointOnLine2 succeeded !!!!
log-file:
http://benjaminhampe@benjaminhampe.be.o ... nLine.html
i would test for other points that are much larger, because substracting tiny from large numbers can produce false results.
but i would guarantee that there are no false positives.
EDIT: the test start to fail if coords of point A are 1000 times larger or smaller than point B