kernel = function(pixels, rotate0, rotate1, rotate2, scale) {
function radius(rho) {
return 2.0 * Math.asin(rho / 2.0);
}
function __radius(rho) {
return Math.asin(rho);
}
function pixelx(lon, srcw) {
lon = frac((lon + 180) / 360);
return Math.floor(lon * srcw);
}
function pixely(lat, srch) {
lat = frac((lat + 90) / 180);
return Math.floor(lat * srch);
}
const x = (this.thread.x / this.constants.w - 1 / 2) / scale,
y = ((this.thread.y - this.constants.h / 2) / this.constants.w) / scale;
const rho = Math.sqrt(x * x + y * y) + 1e-12;
const c = radius(rho),
sinc = Math.sin(c),
cosc = Math.cos(c);
const lambda = Math.atan2(x * sinc, rho * cosc) * 57.29577951308232;
const z = y * sinc / rho;
if (Math.abs(z) < 1) {
const phi = Math.asin(z) * 57.29577951308232;
const lambdan = applyRotation(rotate0, rotate1, rotate2, lambda, phi, 0);
const phin = applyRotation(rotate0, rotate1, rotate2, lambda, phi, 1);
const pixel = pixels[pixely(phin, this.constants.srch)][pixelx(lambdan, this.constants.srcw)];
this.color(pixel[0], pixel[1], pixel[2], 1);
}
}