Thursday, 15 July 2010

java - How to get percentage of how much do two body overlap? -



java - How to get percentage of how much do two body overlap? -

i new in libgdx , want know how can percentage of how much 2 bodies overlap. know need utilize contact listener what? using libgdx in java not c++. there way of getting size of surface of bodies , maybe comparing them somehow? appreciate kind of help. :)

for example.. let´s have 2 bodies (squares) named b1 , b2. 1 of them set sensor can go through each other. , want console prints out percentage of how much overlap when x coordinate same.

for 2 polygons, utilize polygon clipping algorithm find overlapping region. there examples in many languages here: http://rosettacode.org/wiki/sutherland-hodgman_polygon_clipping

for 2 circles it's much easier, should able find how quick google search, eg. http://mathworld.wolfram.com/circle-circleintersection.html

for circle , polygon, i'm not aware of easy or convenient method.

java libgdx box2d

No comments:

Post a Comment