I want to calculate the volume (V) of the part of a sphere, which is the result of the intersection of the sphere with three fingers (x = 0, y = 0 and z = 1.5). I use R language and this is my code. I tried 2 different methods using Cartesian and polar coordinates. Both of them give negative answers.
library("pracma", lib.loc="~/R/win-library/3.1")
f <- function(x, y) (sqrt(4 -x^2 - y^2) - 1.5 )
xmin <- 0
xmax <- 2
ymin <- 0
ymax <- function(x) (sqrt(4 - x^2))
I <- integral2(f, xmin, xmax, ymin, ymax)
I$Q
f0 <- function(x, y) (sqrt(4 - x^2 - y^2)-1.5)
fp <- function(t, r) r * f0(r*cos(t), r*sin(t))
quad2d(fp, 0, pi/2, 0, 2, n = 101)
The correct answer is: V = 0.3600. Can someone give me a hint please?
Greetings
source
share