I'm writing a space game with customisable spaceship shapes, but I'm a bit overwhelmed by a problem, I want to figure out the mass of an irregular 2d shape (the spaceship) based on its area.
The shape itself is stored as a sort of linked list
Point x1, y1 -----> Point x2, y2 ----> Point x3, y3 ----> point x4, y4
and the last point joins back onto the first point. Every 1 unit (unit being 1 integer distance between points) cubed has a mass of 1.
so a triangle of, say:
would have a mass of 17/2 * 12 = 102.
I know I will have to split the main polygon down into triangles, but using every 3 points will not work because sometimes a line back between points could overlap.
I hope I make sense, could I please have any advice on how to go about splitting my shape into triangles.