code: protected WritableRaster shadow( int x, int y, WritableRaster tmpWR, WritableRaster pitWR, double res,
              double[] normalSunVector, double[] inverseSunVector, double[] sunVector ) {
          int n = 0;
          double zcompare = -Double.MAX_VALUE;
          double dx = (inverseSunVector[0] * n);
          double dy = (inverseSunVector[1] * n);
          int nCols = tmpWR.getWidth();
          int nRows = tmpWR.getHeight();
          int idx = (int) (x + dx);
          int jdy = (int) (y + dy);
          double vectorToOrigin[] = new double[3];
          while( idx >= 0 && idx <= nCols - 1 && jdy >= 0 && jdy <= nRows - 1 ) {
              vectorToOrigin[0] = dx * res;
              vectorToOrigin[1] = dy * res;
              vectorToOrigin[2] = pitWR.getSampleDouble(idx, jdy, 0);
              double zprojection = scalarProduct(vectorToOrigin, normalSunVector);
              double nGrad[] = normalVectorWR.getPixel(idx, jdy, new double[3]);
              double cosinc = scalarProduct(sunVector, nGrad);
              double elevRad = elevation;
              if ((cosinc >= 0) && (zprojection > zcompare)) {
                  tmpWR.setSample(idx, jdy, 0, elevRad);
                  zcompare = zprojection;
              }
              n = n + 1;
              dy = (inverseSunVector[1] * n);
              dx = (inverseSunVector[0] * n);
              idx = (int) Math.round(x + dx);
              jdy = (int) Math.round(y + dy);
          }
          return tmpWR;
  
      }
docs: Calculate the angle.
  
  @param x the x index.
  @param y the y index.
  @param tmpWR the sky map.
  @param pitWR the elevation map.
  @param res the resolution of the map.
  @param normalSunVector
  @param inverseSunVector
  @param sunVector