fix AABB2D transform method

pull/18/head
cosmonaut 2022-04-05 16:06:34 -07:00
parent 6a1fa004d6
commit 4b4abaab01
1 changed files with 7 additions and 4 deletions

View File

@ -68,10 +68,13 @@ namespace MoonWorks.Collision
/// <returns></returns> /// <returns></returns>
public static AABB2D Transformed(AABB2D aabb, Transform2D transform) public static AABB2D Transformed(AABB2D aabb, Transform2D transform)
{ {
return new AABB2D( var center = (aabb.Min + aabb.Max) / 2f;
Vector2.Transform(aabb.Min, transform.TransformMatrix), var extent = (aabb.Max - aabb.Min) / 2f;
Vector2.Transform(aabb.Max, transform.TransformMatrix)
); var newCenter = Vector2.Transform(center, transform.TransformMatrix);
var newExtent = Vector2.TransformNormal(extent, AbsoluteMatrix(transform.TransformMatrix));
return new AABB2D(newCenter - newExtent, newCenter + newExtent);
} }
/// <summary> /// <summary>