AForge.NET
AForge.NET copied to clipboard
shapeChecker.IsConvexPolygon: long thin rectangle is not a convex polygon
executing following test fails: It's about a long thin rectangle 50 high and 1000 wide.
2 bugs:
- it is not recognized as convex
- is only has 3 corners instead of 4.
public class SimpleShapeCheckerTest
{
private List<IntPoint> rectangledTriangle = new List<IntPoint>();
public SimpleShapeCheckerTest()
{
longThinRectangle.Add(new IntPoint(0, 0)); //corner
longThinRectangle.Add(new IntPoint(20, 0));
longThinRectangle.Add(new IntPoint(40, 0));
longThinRectangle.Add(new IntPoint(50, 0)); //corner
longThinRectangle.Add(new IntPoint(50, 100));
longThinRectangle.Add(new IntPoint(50, 500));
longThinRectangle.Add(new IntPoint(50, 1000)); // corner
longThinRectangle.Add(new IntPoint(25, 1000));
longThinRectangle.Add(new IntPoint(0, 1000));
longThinRectangle.Add(new IntPoint(0, 500));
}
[TestMethod]
public void IsConvexPolygon()
{
List<IntPoint> corners;
Assert.AreEqual(true, shapeChecker.IsConvexPolygon(rectangle, out corners));
Assert.AreEqual(4, corners.Count);
}