Triangle

BlitzPlus Forums/BlitzPlus Programming/Triangle

MutteringGoblin(Posted 2003) [#1]
Hello,

How do you find the centre of mass for a 2D triangle? I have been just averaging the vertices but I fully expect someone to tell me this is wrong.

Thanks.


Floyd(Posted 2003) [#2]
Averaging is correct.


MutteringGoblin(Posted 2003) [#3]
Oh okay thanks. :)

So following on from that... in Andre Lamothe's book it says you can find the centre of mass of a polygon by attaching a weight to each vertex, multiplying the coordinates of each vertex by its weight, adding all the results together then dividing the final result by the number of vertices... (erm... I think that was it)

But it doesn't explain how you find the correct weight for each vertex. Help??!

EDIT: I suppose I could divide the polygon into triangles first, then find the centre of mass for each of those and average them out. But again I'm not sure if that's right, or if it's the fastest way to do it. :(


Floyd(Posted 2003) [#4]
In general you can replace a region by a single point with all the mass concentrated at that point.

So if you had a collection of triangles and you wanted the overall center of mass you would do:

1. Find the center of mass of each triangle.
2. Multiply these coordinates by the mass ( area ) of the triangle.
3. Add these together.
4. Divide by the total mass.

The hard part is calculating the areas. You would use vector cross product for this.


MutteringGoblin(Posted 2003) [#5]
Thanks Floyd, appreciated.