Added getAABB() methods to Polygon and Circle

With this commit, you can get axis-aligned bounding boxes (AABB) for Polygons and Circles

The `getAABB()` method returns a Box, now. Do you prefer a Polygon?
And is the name `getAABB` OK?
Okay, I'll change that tonight or tomorrow, and resubmit.
On Dec 25, 2014 12:06 AM, Jim Riecken <notifications@github.com> wrote:In SAT.js:
> @@ -414,6 +424,37 @@
>      }
>      return this;
>    };
> +  
> +  
> +  // Compute the axis-aligned bounding box
> +  /**
> +   * @return {Box} The AABB
> +   */
> +  Polygon.prototype["getAABB"] = Polygon.prototype.getAABB = function() {

This method will return the AABB of the polygon before any calculated translations/rotations are applied.

E.g if I do:

var myPoly = new Box(new Vector(0,0), 100, 100).toPolygon();
myPoly.setAngle(Math.PI / 4);
var myAABB = myPoly.getAABB();


It will return the bounding box for the original box, not the diamond resulting from the rotation. (It will work if rotate is called instead of setAngle)

I think if you change this to use calcPoints rather than points it will always return the AABB of a snapshot of the current state of the Polygon, which I think is a more predictable behavior for the method.

—Reply to this email directly or view it on GitHub.