simple 2d polygon intersection

Hello,

I didn’t find much that could help me using the search function, so maybe somebody can just point me to the right place.

I can’t find anything in Java for doing 2D polygon intersection. I want to be able to rotate the baddies on the screen, and do intersection/collision tests with bounding boxes/polygonal hit boxes. I was hoping that there is something burried in Java 1.5 that I don’t know of yet.

I could get away with using simple rectangles, as long as they can be rotated.

Thanks guys. I havn’t posted here in a LONG time, but I always find something useful when I need it.

Just take a look at java.awt.geom package - all you need is there.

You can check out some java2d tutorials over here:
http://java.sun.com/j2se/1.4.2/docs/guide/2d/index.html

Dmitri

… OMG.

There it is. I have been looking through here repeatedly for a while. It looks like the thing I want to use is called an “Area”. I had looked through all of the OTHER shapes, and seen that they all behave the same way.

The Area on the other hand, can be transformed using AffineTransformations(yay!), and it’ll do any of the basic geom operations that I need(like intersect).

Thanks. Sometimes, there is just so much stuff in the library, that you have trouble finding exactly what you need.

'nother hint:
area.intersect(otherArea);
(!area.isEmpty())

:slight_smile: