# How to make 2d AABB (axis aligned bounding box)?

Screenshot by Lightshot - example

How can we create an AABB of a rectangle which is being rotated all the time? And how can we acess the points in which the two intersect?

Uhm isn’t that the same thing you asked [over here][1]. As i said in my answer on your other question if you want to find top-most / bottom-most / left-most / right-most corner of your actual object you can’t use the AABB as it’s just the bounding box that encloses your whole object which is aligned with the world axes.

If you want to know the exact point of a localspace position you have to use TransformPoint. But again, as i said in my other answer which localspace point you have to use depends on what your object actually is (3D plane / quad or a 2D sprite) what it’s size is ect… You didn’t say anything specific in neither of your two questions.

If you use a SpriteRender and a Sprite you can use something like this:

``````public static Vector3[] GetSpriteCorners(SpriteRenderer aSprite)
{
// sprite.bounds is in local space
var b = aSprite.sprite.bounds;
var res = new Vector3[]
{
new Vector3(b.min.x,b.min.y),
new Vector3(b.min.x,b.max.y),
new Vector3(b.max.x,b.max.y),
new Vector3(b.max.x,b.min.y)
};
var t = aSprite.transform;
// transform the corners into worldspace
for (int i = 0; i < res.Length; i++)
{
res _= t.TransformPoint(res*);*_
``````

}
return res;
}
So just pass the reference to a SpriteRenderer to this method and you get back an array of all 4 corners in worldspace.