#### Archived

This topic is now archived and is closed to further replies.

# Mass calculation problem

This topic is 5864 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I wonder how I should calculate the mass of a 3D object, knowing its mass per volume. In fact, the real problem would be to check whether a point is inside or outside an object, without making hypotheses about the object (it''s not a sphere, or a box, or anything simple. Just tons of polygons). I thought about doing a cubic rendering from this point (ie render in all 6 directions), but I don''t think it''s an easy (and fast!) method. Could anyone help me?

##### Share on other sites
Look into tetrahedralization.

First, think about triangulation. You have a random polygon. It can be concave, etc. Now split it into triangles. You can find the area of each triangle, and then add those areas.

Extend the idea to 3d. Instead of using triangles, use tetrahedrons (A 3-sided pyramid is a tetrahedron). Then you can compute the volume of each tetrahedron. Add all the volumes.

Multiply volume by density, and you''ve got mass.

I''ll post again withs ome other ideas.

##### Share on other sites
There is a relatively simple method. I''ll explain it in 2D first.

Suppose we are given a polygon. Using coordinates (x,y), a segment is the ordered pair (x1,y1),(x2,y2). Let''s assume that all y coordinates are positive, just to visualize the image better. We compute the area below a segment as
A = (y1+y2)/2*(x2-x1)
Don''t take any absolute values here. If the segment is going in the other direction, we consider it''s area negative. Do this for every side of your polygon (order doesn''t matter), add the results, and there you go: that''s the area of you polygon. Well, you may have to call abs() now. This works because the zones outside the polygon are counted the same number of times positively and negatively, so they cancel out.

In 3D, do the same for every side of your object.
V = (z1+z2+z3)/3*Area_of_triangle((x1,y1),(x2,y2),(x3,y3))
Don''t take any absolutes values in this formula either. Everything has to preserve signs to indicate orientation.

As long as your object is closed and the sides have a consistent orientation, the sum will be the volume you are looking for.

I hope that helps.

##### Share on other sites
Thanks a lot for your replies.
I also need a formula to determinate an inertia matrix. I know that the general formula (with an integral), but I don''t know how to implement it, and I don''t think your methods could help for it.
Have you got other ideas for this matrix?

##### Share on other sites
I''ve seen some posts here about finding the inertial matrix here, but I don''t remember the responses. You may be able to find some old posts. I''ll leave answering this question to someone else. From the little I do remember, though, most solutions involved tetrahedralization.

I''m primarily posting back about finding the volume of an arbitrary polygonal hull. Alvaro''s method is pretty amazing, so I guess you''re going to use it, but I''m going to have to think about it a little bit. Here''s another idea though. It''s a raster-inspired approach. First imagine it in 2d, with a polygon. Find the bounding box of the polygon, and, scanning across box in "how you read" order (like pixels on a screen), you do a simple in/out test. (If the point is behind all polygons, it''s in). Multiply the number of points that are inside by the area of a grid square to determine the approximate area of the polygon. Now use this idea with cubes instead of squares, and you''re good. For even better results, subdivide the edges of your grid recursively. All this is very simple to code, and visualize, so I''d figure I''d post it here. From the sounds of things, though, alvaro''s technique is better. I still need to give it some thought though.

1. 1
Rutin
69
2. 2
3. 3
4. 4
5. 5

• 21
• 10
• 33
• 20
• 9
• ### Forum Statistics

• Total Topics
633430
• Total Posts
3011831
• ### Who's Online (See full list)

There are no registered users currently online

×