This project is read-only.
1
Vote

Bug in Triangle.GetArea() function

description

I have found a bug in Triangle class.
GetArea() function calculates the area from 3 vectors given.
And there is also a description how it's calculating, but the implementation is wrong.
There is :
return 0.5f * ((_p1.X - _p0.X) * (_p2.Y - _p0.Y)) - ((_p2.X - _p0.X) * (_p1.Y - _p0.Y));
and it should be :
return 0.5f * ( ((_p1.X - _p0.X) * (_p2.Y - _p0.Y)) - ((_p2.X - _p0.X) * (_p1.Y - _p0.Y)) );
 
It's not so much, but it returns wrong value.

comments