#x3D; Math.atan2(dzdy, -dzdx);
            if (aspect &lt; 0) {
              aspect &#x3D; halfPi - aspect;
            } else if (aspect &gt; halfPi) {
              aspect &#x3D; twoPi - aspect + halfPi;
            } else {
              aspect &#x3D; halfPi - aspect;
            }

            cosIncidence &#x3D; sinSunEl * Math.cos(slope) +
                cosSunEl * Math.sin(slope) * Math.cos(sunAz - aspect);

            offset &#x3D; (pixelY * width + pixelX) * 4;
            scaled &#x3D; 255 * co