[Closed] Volume of a fluid
Hello everyone!
I’m student architecture and I’m scripting a plugin of a primitive. A little bottle, glass object. In adding the parameters, I want to be able to change the volume of the bottle. Therefore a need ofcourse a manner to calculate the volume of the fluid inside the bottle.
It’s a very organic design. So i think that i will be a very complex integral maths calculation.
Does somebody deal with this kind of problems?
Regards!
–Jazz-arch
If you can build a closed mesh representation of the fluid (using the internal faces of the bottle), the Volume&CenterOfMass function in the MAXScript Reference should give you the same volume as the Measure utility, regardless of the complexity of the shape. Of course, the value would be an approximation since you are using polygons, but it should be pretty accurate.
There are a couple of ways to do this. Two questions I’d ask first are, how accurate does the calculation have to be and is the volume guaranteed to be convex? If accuracy isn’t too much of an issue, you can look at using voxels (the 3d equivalent to pixels. Like a 3d grid.) to estimate the volume. The more voxels you use, the more accurate the calculation will be, but the longer it will take. If it’s gauranteed to be convex, then you can pick a point in the middle and shoot rays out to find the intersection points and use that to calculate the grid.
Also, since you’re building the object yourself, you can calculate the volume from each face as it move toward an known object. For example, build the largest box you can fit into the space and then calculate the volume of each face as it moves to the box. This one’s not easy if you have a highly complex object, but it will give 100% accurate results.
Thank you all!!
the question is indeed how accurate does the calculation have to be? Not that accurate I suppose. Because afterwards there will be made a negative form with a cnc machine and then they blow some glass in it.
I’m going to try the VolumeAndCenterOfMass method. This should suffice.
Regards.
–J-arch