fix point not being transformed

generics
thatcosmonaut 2019-12-02 12:47:27 -08:00
parent 1d9c523cb2
commit ec3e63e5e2
2 changed files with 7 additions and 5 deletions

View File

@ -26,7 +26,7 @@ namespace MoonTools.Core.Bonk
public Vector2 Support(Vector2 direction, Transform2D transform)
{
return position;
return Vector2.Transform(position.ToVector2(), transform.TransformMatrix);
}
public override bool Equals(object obj)
@ -64,4 +64,4 @@ namespace MoonTools.Core.Bonk
return !(a == b);
}
}
}
}

View File

@ -11,7 +11,8 @@ namespace Tests
[Test]
public void PointLineOverlapping()
{
var point = new Point(1, 1);
var point = new Point(-3, -3);
var pointTransform = new Transform2D(new Position2D(4, 4));
var line = new Line(new Position2D(-2, -2), new Position2D(2, 2));
GJK2D.TestCollision(point, Transform2D.DefaultTransform, line, Transform2D.DefaultTransform).Should().BeTrue();
@ -41,10 +42,11 @@ namespace Tests
[Test]
public void PointCircleNotOverlapping()
{
var point = new Point(3, 0);
var point = new Point(0, 0);
var pointTransform = new Transform2D(new Position2D(3, 0));
var circle = new Circle(1);
GJK2D.TestCollision(point, Transform2D.DefaultTransform, circle, Transform2D.DefaultTransform).Should().BeFalse();
GJK2D.TestCollision(point, pointTransform, circle, Transform2D.DefaultTransform).Should().BeFalse();
}
[Test]