Search code examples
javaandroidgeometrycollision-detectionpolygon

How do I test overlap (or collision) of two arbitrary shapes


I'm looking for a Java library which I can use to compute the collision of two simple (no intersecting lines or holes) 2D polygons.

The specific implementation is a drag-and-drop "sticker" applicator where the user drags various solid shapes around the screen and the shapes may not overlap.

I have a vague idea of how to write this myself but am hoping to avoid reinventing this bicycle, however, after a number of searches I'm unable to find anything useful.


Solution

  • Box2D

    Features

    Rigid body physics
    Stable stacking
    Gravity
    Fast persistent contact solver
    Dynamic tree broadphase
    Sliding friction
    Boxes, circles, edges and polygons
    Several joint types: distance, revolute, prismatic, pulley, gear, mouse
    Motors Sleeping (removes motionless bodies from simulation until touched)
    Continuous collision detection (accurate solving of fast bodies)
    Ray casts
    Sensors
    Serialization
    Dynamic, Kinematic, and Static bodies
    Liquid particle simulation from Google's LiquidFun