I come back to you about the library GeoMan that I shared some time ago which was quite messy and I didn't really know where I was going with it. The first goal was one of the functions related to the polygons (most of which were themselves readjusted from another library itself not very "clean") to make my life easier in a game I was making at the time which required also full of geometric functions, which resulted in this big pile of unsightly code .
Some time ago I therefore tried to roll up my sleeves to make it a library only focused on polygons that can fully manage collisions, ie which also returns the necessary to replace the shapes. And so here it is, I share my work with you if it can be useful to others
The link to the GitHub repo: https://github.com/Bigfoot71/PolyMan/tree/main
Here is a small "technical demo"
Here is the list of functions, without going into details (I'll do a readme on github when I have time):
- getSignedArea
getArea
getPerimeter
getCenter
getCentroid
getClosestVertice
getBoundingBox
getDistanceBetweenPolys
setReverse
setTransform
setTranslation
setPosition
setRotation
setScale
isCCW
isConvex
isComplex
- create.triangle
create.rectangle
create.ellipse
create.circle
create.donut
create.random
- collisions.pointInPolyFast -> (Detect collision only)
collisions.pointInPoly -> (Returns normals and distance)
collisions.polyInPolyFast -> (Detect collision only)
collisions.polyInPolyConvex -> (Returns normals and distance)
collisions.polyInPolyAABB -> (Returns normals and distance)
collisions.segmentPoly -> (Detect collision only)
- operations.boolean
operations.simplify
operations.convexHull
operations.reduceVerts
NB: If you have better ideas for naming the functions I'm all ears!