in my program i have a piece of code like this -

int left_count, right_count;

left_count = right_count = 0;

for all triangles

{

a = condition that x coordinates of all vertices are <= split.x

b = condition that x coordinates of all vertices that are >= split.x

if(a is true)

left_count++;

else

if(b is true)

right_count++;

else

if(!a && !b)

{

left_count++;

right_count++;

}

}

Now with the above code, I get left_count as 1200 and right_count 619

When I did not have the else if(!a && !b), I was getting 581 and 581

which is 1162 i.e. triangles which are only in left box and only in

right box . Not the ones that belong to both left and right boxes. So

that means triangles which are on both sides totals to about 38. I

believe 619 for right_count is correct but theres something fishy

about lefT_count which should also be 619 or so in my opinion. Prior

to changing the code in the above manner i had if cases like below -

if(a is true)

left_count++;

if(b is true)

right_count++;

else

{

left_count++;

right_count++;

}

And I was getting left_count and right_count as 1200 and 1200 which

was quite surprising to see.

**actual code **

for(i=0; i<(*kd)->maxtriangles; i++)

{

a = (*kd)->v[(*kd)->t[i].v0].x <=(*kd)->split.x && (*kd)->v[(*kd)-

>t[i].v1].x <= (*kd)->split.x &&(*kd)->v[(*kd)->t[i].v2].x <= (*kd)-

split.x;

b = (*kd)->v[(*kd)->t[i].v0].x <=(*kd)->split.x && (*kd)->v[(*kd)-

>t[i].v1].x <= (*kd)->split.x &&(*kd)->v[(*kd)->t[i].v2].x <= (*kd)-

split.x;

if(a)

left_count++;

if(b)

right_count++;

else

if(!a && !b)

{

left_count++;

right_count++;

}

}