Volume of 3d shape using numerical integration with scipy
问题 I have written a function for computing volume of intersection of a cube and a half-space and now I'm writing tests for it. I've tried computing the volume numerically like this: integral = scipy.integrate.tplquad(lambda z, y, x: int(Vector(x, y, z).dot(normal) < distance), -0.5, 0.5, lambda x: -0.5, lambda x: 0.5, lambda x, y: -0.5, lambda x, y: 0.5, epsabs=1e-5, epsrel=1e-5) ... basically I integrate over the whole cube and each point gets value 1 or 0 based on if it is inside the half