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
773247
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;

    }
901492
def angle( x, y ):
    
    dot = np.dot( x, y )
    x_mod = np.linalg.norm( x )
    y_mod = np.linalg.norm( y )
    cos_angle = dot / ( x_mod * y_mod )
    return np.degrees( np.arccos( cos_angle ) )
314924
def north_pole_uvw(self):
        """"""
        # TODO: is this rpole scaling true for all distortion_methods??
        rpole = self.instantaneous_rpole*self.sma
        return self.polar_direction_uvw*rpole+self.mesh._pos
60709
@SuppressWarnings("checkstyle:magicnumber")
	public void setRotation(double angle) {
		final double[] tmpScale = new double[3];
		final double[] tmpRot = new double[9];
		getScaleRotate2x2(tmpScale, tmpRot);
		final double cos = Math.cos(angle);
		final double sin = Math.sin(angle);
		// R * S
		this.m00 = tmpScale[0] * cos;
		this.m01 = tmpScale[1] * -sin;
		this.m10 = tmpScale[0] * sin;
		this.m11 = tmpScale[1] * cos;
		// S * R
		//		this.m00 = tmp_scale[0] * cos;
		//		this.m01 = tmp_scale[0] * -sin;
		//		this.m10 = tmp_scale[1] * sin;
		//		this.m11 = tmp_scale[1] * cos;
	}
651386
public static <S extends Solution<?>> void angleUtility(List<S> solutionsList, double[][] extremePoints) {
    for (S solution : solutionsList) {
      double fraction = 0.0;
      for (int i = 0; i < extremePoints.length; i++) {
        double numerator = 0.0;
        double denominator = 0.0;
        for (int j = 0; j < extremePoints.length; j++) {
          if (i == j) {
            denominator = Math.abs(extremePoints[i][j] - solution.getObjective(j));
          } else {
            numerator += Math.pow(extremePoints[i][j] - solution.getObjective(j), 2.0);
          }
        }
        // Avoid numeric instability and division by 0.
        if (denominator > 10e-6) {
          fraction = Math.max(fraction, Math.sqrt(numerator) / denominator);
        } else {
          fraction = Double.MAX_VALUE;
        }
      }
      setScalarizationValue(solution, Math.atan(fraction));
    }
  }
591573
def angle(self, vector):
        """"""
        return math.degrees(
            math.acos(
                self.dot(vector) /
                (self.magnitude() * vector.magnitude())
            )
        )
210984
def estimate_angle(angle, origin, new_frame, offset=1e-7):
    
    from astropy.coordinates import SkyCoord
    import astropy.units as u
    angle_deg = angle*np.pi/180
    newlat = offset * np.cos(angle_deg) + origin.data.lat.degree
    newlon = (offset * np.sin(angle_deg) / np.cos(newlat * np.pi/180) + origin.data.lon.degree)
    sc = SkyCoord(newlon, newlat, unit='degree', frame=origin.frame.name)
    new_origin = origin.transform_to(new_frame)
    new_sc = sc.transform_to(new_frame)
    return new_origin.position_angle(new_sc).deg
1283986
private void calcPrincipalRotationVector() {
		Rotation rotation = rotationGroup.getRotation(0); // the rotation around the principal axis is the first rotation
		AxisAngle4d axisAngle = rotation.getAxisAngle();
		principalRotationVector = new Vector3d(axisAngle.x, axisAngle.y, axisAngle.z);
	}
718309
public void setRoundRect (float x, float y, float width, float height,
                              float arcwidth, float archeight) {
        this.x = x;
        this.y = y;
        this.width = width;
        this.height = height;
        this.arcwidth = arcwidth;
        this.archeight = archeight;
    }
618740
public static Geometry computeShadow(Geometry geometry, double azimuth, double altitude, double height) {
        return computeShadow(geometry, azimuth, altitude, height, true);
    }
1307999
public static Array2DRowRealMatrix getRadiusOfGyrationTensor(Trajectory t){
		double meanx =0;
		double meany =0;
		for(int i = 0; i < t.size(); i++){
			meanx+= t.get(i).x;
			meany+= t.get(i).y;
		}
		meanx = meanx/t.size();
		meany = meany/t.size();
		
		double e11 = 0;
		double e12 = 0;
		double e21 = 0;
		double e22 = 0;
		
		for(int i = 0; i < t.size(); i++){
			e11 += Math.pow(t.get(i).x-meanx,2);
			e12 += (t.get(i).x-meanx)*(t.get(i).y-meany);
			e22 += Math.pow(t.get(i).y-meany,2);
		}
		e11 = e11 / t.size();
		e12 = e12 / t.size();
		e21 = e12;
		e22 = e22 / t.size();
		int rows = 2;
		int columns = 2;
		Array2DRowRealMatrix gyr = new Array2DRowRealMatrix(rows, columns); 
		
		gyr.addToEntry(0, 0, e11);
		gyr.addToEntry(0, 1, e12);
		gyr.addToEntry(1, 0, e21);
		gyr.addToEntry(1, 1, e22);
		
		return gyr;
	}
191849
def angle(v1, v2):
    """"""
    v1_u = unit_vector(v1)
    v2_u = unit_vector(v2)
    return np.arccos(np.clip(np.dot(v1_u, v2_u), -1.0, 1.0))
312312
def _calculate_sun_vector(self):
        """"""
        z_axis = Vector3(0., 0., -1.)
        x_axis = Vector3(1., 0., 0.)
        north_vector = Vector3(0., 1., 0.)

        # rotate north vector based on azimuth, altitude, and north
        _sun_vector = north_vector \
            .rotate_around(x_axis, self.altitude_in_radians) \
            .rotate_around(z_axis, self.azimuth_in_radians) \
            .rotate_around(z_axis, math.radians(-1 * self.north_angle))

        _sun_vector.normalize()
        try:
            _sun_vector.flip()
        except AttributeError:
            # euclid3
            _sun_vector = Vector3(-1 * _sun_vector.x,
                                  -1 * _sun_vector.y,
                                  -1 * _sun_vector.z)

        self._sun_vector = _sun_vector
659012
private static double[] calculateParameters( final double[][] elevationValues ) {
        int rows = elevationValues.length;
        int cols = elevationValues[0].length;
        int pointsNum = rows * cols;

        final double[][] xyMatrix = new double[pointsNum][6];
        final double[] valueArray = new double[pointsNum];

        // TODO check on resolution
        int index = 0;
        for( int y = 0; y < rows; y++ ) {
            for( int x = 0; x < cols; x++ ) {
                xyMatrix[index][0] = x * x; // x^2
                xyMatrix[index][1] = y * y; // y^2
                xyMatrix[index][2] = x * y; // xy
                xyMatrix[index][3] = x; // x
                xyMatrix[index][4] = y; // y
                xyMatrix[index][5] = 1;
                valueArray[index] = elevationValues[y][x];
                index++;
            }
        }

        RealMatrix A = MatrixUtils.createRealMatrix(xyMatrix);
        RealVector z = MatrixUtils.createRealVector(valueArray);

        DecompositionSolver solver = new RRQRDecomposition(A).getSolver();
        RealVector solution = solver.solve(z);

        // start values for a, b, c, d, e, f, all set to 0.0
        final double[] parameters = solution.toArray();
        return parameters;
    }
1008521
public static double[] calcNormalSunVector( double[] sunVector ) {
        double[] normalSunVector = new double[3];
        normalSunVector[2] = Math.sqrt(Math.pow(sunVector[0], 2) + Math.pow(sunVector[1], 2));
        normalSunVector[0] = -sunVector[0] * sunVector[2] / normalSunVector[2];
        normalSunVector[1] = -sunVector[1] * sunVector[2] / normalSunVector[2];
        return normalSunVector;
    }
273660
def angle( vertex_index )
      return nil if(vertex_index < 0 || vertex_index > 2)
      vert1 = self.vertices[vertex_index]
      vert2 = self.vertices[(vertex_index+1)%3]
      vert3 = self.vertices[(vertex_index+2)%3]
      vec1 = vert2 - vert1
      vec2 = vert3 - vert1
      vec1.angle(vec2)
    end
111761
protected void calculatePointerAngle() {
        float progressPercent = ((float) mProgress / (float) mMax);
        mPointerPosition = (progressPercent * mTotalCircleDegrees) + mStartAngle;
        mPointerPosition = mPointerPosition % 360f;
    }