float x1 = x[0]; float y1 = x[1]; float z1 = x[2]; double d = sqrt(x1*x1 + y1*y1 + z1*z1); if(d == 0) return 0; double c = z1/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; //GOOD COMBINATION float sphere = 1.0 - xt*xt/225 - yt*yt/225 - zt*zt/225; float cube = R_int(R_int(1.0 - fabs(xt)/12, 1.0 - fabs(yt)/12), 1.0 - fabs(zt)/12); //BAD COMBINATION //float sphere = 255.0 - xt*xt - yt*yt - zt*zt; //float cube = R_int(R_int(12 - fabs(xt), 12 - fabs(yt)), 12 - fabs(zt)); return R_int(cube, -sphere);