Calculate intersecting volume without boolean intersection

Hi all!

I’m making a tool to create and modify a ring by using grabbable kangaroo points to alter the shape. I’ve managed to keep the script fast enough so that dragging the points doesn’t feel jittery or laggy by only doing the boolean operations at the very end with a toggle.

The finished ring is a boolean difference of a circular pipe and a cylinder. I want to calculate the volume of the finished ring after boolean difference in real time, but seeing as a boolean operation makes the script laggy, I don’t know how to proceed.

Is there a way, maybe with a custom script, to calculate the intersecting volume of the cylinder and pipe so that I can subtract it from the volume of the pipe?

See the image for what I mean.

are the cylinder and the torus both perfect regular solids, and do they always share the same vertical axis?

1 Like

They’re both closed breps and they always have the same vertical axis.

I suppose you can make make bounding boxes for the objects, then calculate the overlapping volume of these, and then calculate volumepoints as “voxels” of this and check each point to see if it is inside both objects, but I don’t know how fast/slow this will be.

I don’t really understand this part. So you want to do a boolean operation anyway or do you just want to calculate this mathematically?

You can calculate the volume with this formula:

You need to know the area of the profile curve and the x coordinate of the center point.

Here’s a comparison with a revolution and volume component:

volume_trimmed_torus.gh (12.9 KB)

2 Likes

This (below) is more like what you want, eh?
Using that “ring” that can be stretched with Kangaroo.

1 Like

I want to the boolean operation, but only in the end. If I enable the boolean component while editing the ring, the edits I do are jittery and laggy. If I first do all the edits and only then do the boolean operation, the process runs smoother.

But I want to know the volume of the end result before actually doing the boolean.

The volume as a number?

This could work, but I wasn’t clear on the editing of the ring.
The idea is to make the ring thicker or thinner at certain points and adjust the height, as shown in the picture.
I can get multiple sections, but this formula probably won’t work then?

And this is why you should upload a file at the start.

1 Like

Yeah this does not work. I think you’ll have to use the boolean intersection.