0

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.

Yevgeny Simkin
  • 27,946
  • 39
  • 137
  • 236
  • This is completely off topic, but this here: http://www.jbox2d.org/ I have never used it myself. – WalterM Nov 17 '15 at 21:56
  • @WalterM, how is that "off topic"? Looks like exactly what I'm looking for! I'll give it a whirl and see if it has what I need. You should propose this as an answer, I'll upvote it! :) – Yevgeny Simkin Nov 17 '15 at 22:04
  • @MadProgrammer, that looks like a collision test for rectangles - I need it to work on arbitrary shapes - am I overlooking its capacity to deal with this use case? – Yevgeny Simkin Nov 17 '15 at 22:11
  • You could also have a look at [this example](http://stackoverflow.com/questions/20927189/detecting-collision-of-two-sprites-that-can-rotate/20928531#20928531) – MadProgrammer Nov 17 '15 at 22:13
  • 2
    [Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.](http://stackoverflow.com/help/on-topic) – Turing85 Nov 17 '15 at 22:14
  • If you make use of the Shape API, then the previous and new link will still work, I just used rectangles cause they were simple to implement ;). I'm not sure how much of the API is available in android though. The newer example goes into more details about how you might actually make use it – MadProgrammer Nov 17 '15 at 22:15
  • @Turing85, Ironic handle given that I'm not sure if your comment was auto generated by an algorithm searching questions for the word "library", but if you are not a bot and consider my question you'll observe that the whole point of it is that I am not finding "what has been done before to solve it" but am assuming that it does have a pre-existing solution; It is this solution that I'm seeking. – Yevgeny Simkin Nov 17 '15 at 22:20
  • @MadProgrammer, ah, indeed that's precisely what I need... sadly it's all in Swing. – Yevgeny Simkin Nov 17 '15 at 22:23

1 Answers1

2

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

Community
  • 1
  • 1
WalterM
  • 2,686
  • 1
  • 19
  • 26