Mass calculation problem
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?
mikamikazzzzzzzzzzzz
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.
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.
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.
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.
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?
Thanks in advance.
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?
Thanks in advance.
mikamikazzzzzzzzzzzz
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement