float x1 = x[0]*1.2f; float y1 = x[1]*1.2f; float z1 = x[2]*1.2f; double d = sqrt(x1*x1 + y1*y1 + (z1-5)*(z1-5)); if(d == 0) return 0; double c = (z1-5)/d; if(c > 1.0) c = 1; else if(c < -1.0) c = -1; double angle2 = 3.0*asin(c); float xt = x1*cos(angle2) - y1*sin(angle2); float yt = x1*sin(angle2) + y1*cos(angle2); float zt = z1; float upper = R_int(-(zt-15)- fabs(xt), -(z1-15) - fabs(yt)); float lower = R_int((zt+15)- fabs(xt), (z1+15) - fabs(yt)); return R_int(upper, lower);