Reputation: 177
anybody can explain me epsilon what is this term although i did not use in my header file. like
Right (const lPoint& a, const lPoint& b, const lPoint& c, double epsilon)
{
#if _NOT_USED_EPSILON
return (( (a.x_ * b.y_) - (a.y_ * b.x_) +
(a.y_ * c.x_) - (a.x_ * c.y_) +
(b.x_ * c.y_) - (c.x_ * b.y_) ) < 0);
#else
/* return (( (a.x_ * b.y_) - (a.y_ * b.x_) +
(a.y_ * c.x_) - (a.x_ * c.y_) +
(b.x_ * c.y_) - (c.x_ * b.y_) ) < -SPATIAL_EPSILON);*/
if( epsilon == -1 )
return (b.x_-a.x_)*(c.y_-a.y_)-(c.x_-a.x_)*(b.y_-a.y_) < -SPATIAL_AREA_EPSILON;
else
return (b.x_-a.x_)*(c.y_-a.y_)-(c.x_-a.x_)*(b.y_-a.y_) < -epsilon;
#endif
}
here i did not used epsilon in my file than wy we are saying that #if _not_used_epsilon than return this .... while my epsilon by default is 0 because its mot initialized. but its use din if condition and her const is used because it will not change the value of arguemnt. right!
and this #if will not read by complier inside the function i want to ask that #directory are read by coompiler or not.. i am not getting #directories.. why we use it we can sue simple if condition with variables as we use in function,, so why #directory inside the main.. who will deal with it compiler..
Upvotes: 0
Views: 216
Reputation: 145419
#if
is a preprocessor directive.
Read up on the preprocessor in your C++ textbook.
Upvotes: 0
Reputation: 25537
This code is simple. What it does is this?
If the preprocessor symbol _NOT_USED_EPSILON
is defined (through make file, command line) etc, then the expression is checked if it is less than 0.
In some cases (since double arithmetic looses precision), one may check the value of the expression if it is significantly close to 0.
If such precision arithmetic is required then the make file would undefine the preprocessor symbols _NOT_USED_EPSILON
.
In such a case, the expression will be checked with the value of the last argument to your function (epsilon).
Note that _NOT_USED_EPSILON
is not read by the compiler but is a preprocessor directive.
From the OP, the code below is compiled only when _NOT_USED_EPSILON
is defined, else it is not.
return (( (a.x_ * b.y_) - (a.y_ * b.x_) +
(a.y_ * c.x_) - (a.x_ * c.y_) +
(b.x_ * c.y_) - (c.x_ * b.y_) ) < 0);
Upvotes: 2