But draw the triangle (0,0)(1,0)(2,0)! Ofcourse the area is 0, because we have three points in one line.

Use (0,0), (2,3) and (4,1) to check.

cecsFTL commented: Very helpful! +1

OH MAN HAHA ! You're the greatest hiddepolen :D

Thanks for everything and putting up with my nonsense.


Thanks, good luck!

Glad that hiddpolen helped you solve your problem.

Anyway, one comment on the condition.

return !(a+b<c || b+c<a || a+c<b || a == 0 || b == 0 || c == 0);

This is actually the same as what I suggested earlier (add the = sign).

return !(a+b<=c || b+c<=a || a+c<=b);

The reason is whenever a side of 3 points is 0, other 2 sides will always be the same regardless. I am not saying that doing the before is wrong. It is just a way of thinking when you do programming. It just make the code look cleaner and more succinct.

You are right, I see it now. Good suggestion, my thinking was twisted exactly the other way :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.