Friday, 13 September 2013

Distance of two Rectangle Center's Connecting Line Outside of the Rectangles

Distance of two Rectangle Center's Connecting Line Outside of the Rectangles

Well excuse me for the long title, i dont really know how to call it.

I would like you to explain me how to calculate the image's red line's
length, knowing the rectangles position and dimensions.
Context: I need this for a 2d game collision response since when the
length is negative it means not only they are intersecting but also that
length is the distance they have to repel each other to stop being
collided. If there's an easier way to do this, even better.

No comments:

Post a Comment