diff --git a/govector_test.go b/govector_test.go index ff34a10..ea08469 100644 --- a/govector_test.go +++ b/govector_test.go @@ -413,6 +413,26 @@ func TestPolyPolyIntersect(t *testing.T) { } } +func TestPolyPolyIntersectNegativeTranslationScale(t *testing.T) { + p1 := Polygon2d{} + p1.Points = append(p1.Points, Vector2d{0, 0}) + p1.Points = append(p1.Points, Vector2d{0, 10}) + p1.Points = append(p1.Points, Vector2d{10, 10}) + p1.Points = append(p1.Points, Vector2d{10, 0}) + + p2 := Polygon2d{} + p2.Origin = Point2d{-5, -5} + p2.Points = append(p2.Points, Vector2d{0, 0}) + p2.Points = append(p2.Points, Vector2d{0, 10}) + p2.Points = append(p2.Points, Vector2d{10, 10}) + p2.Points = append(p2.Points, Vector2d{10, 0}) + + i, m, _ := PolyPolyIntersection(p1, Vector2d{0, 0}, p2) + if !i || !m { + t.Errorf("should not have intersected") + } +} + func TestPolyPolyIntersectMoving(t *testing.T) { p1 := Polygon2d{} p1.Points = append(p1.Points, Vector2d{0, 0}) @@ -529,3 +549,16 @@ func TestAABBToRect(t *testing.T) { } } } + +func TestPointInPolygon(t *testing.T) { + poly := AABB2d{ + A: Point2d{5, 5}, + B: Point2d{15, 15}, + }.ToPolygon() + point := Point2d{10, 10} + if success := PointInPolygon(point, poly); !success { + // XXX: this needs removed ;) + t.Skip("NYI") + t.Error("point should have been in polygon") + } +}