Compute the angle for a sparse and a dense vector.

@param v1 Sparse first vector
@param v2 Dense second vector
@return angle
763870
public static double angleSparseDense(SparseNumberVector v1, NumberVector v2) {
    // TODO: exploit precomputed length, when available.
    final int dim2 = v2.getDimensionality();
    double l1 = 0., l2 = 0., cross = 0.;
    int i1 = v1.iter(), d2 = 0;
    while(v1.iterValid(i1)) {
      final int d1 = v1.iterDim(i1);
      while(d2 < d1 && d2 < dim2) {
        final double val = v2.doubleValue(d2);
        l2 += val * val;
        ++d2;
      }
      if(d2 < dim2) {
        assert (d1 == d2) : "Dimensions not ordered";
        final double val1 = v1.iterDoubleValue(i1);
        final double val2 = v2.doubleValue(d2);
        l1 += val1 * val1;
        l2 += val2 * val2;
        cross += val1 * val2;
        i1 = v1.iterAdvance(i1);
        ++d2;
      }
      else {
        final double val = v1.iterDoubleValue(i1);
        l1 += val * val;
        i1 = v1.iterAdvance(i1);
      }
    }
    while(d2 < dim2) {
      final double val = v2.doubleValue(d2);
      l2 += val * val;
      ++d2;
    }
    final double a = (cross == 0.) ? 0. : //
        (l1 == 0. || l2 == 0.) ? 1. : //
            FastMath.sqrt((cross / l1) * (cross / l2));
    return (a < 1.) ? a : 1.;
  }
724921
def dot_v2(vec1, vec2):
    """"""

    return vec1.x * vec2.x + vec1.y * vec2.y
162247
public double getAngleValue(String id1, String id2, String id3) {
        String akey = "";
        if (pSet.containsKey(("angle" + id1 + ";" + id2 + ";" + id3))) {
            akey = "angle" + id1 + ";" + id2 + ";" + id3;
        } else if (pSet.containsKey(("angle" + id3 + ";" + id2 + ";" + id1))) {
            akey = "angle" + id3 + ";" + id2 + ";" + id1;
        } else if (pSet.containsKey(("angle" + id2 + ";" + id1 + ";" + id3))) {
            akey = "angle" + id2 + ";" + id1 + ";" + id3;
        } else if (pSet.containsKey(("angle" + id1 + ";" + id3 + ";" + id2))) {
            akey = "angle" + id1 + ";" + id3 + ";" + id2;
        } else if (pSet.containsKey(("angle" + id3 + ";" + id1 + ";" + id2))) {
            akey = "angle" + id3 + ";" + id1 + ";" + id2;
        } else if (pSet.containsKey(("angle" + id2 + ";" + id3 + ";" + id1))) {
            akey = "angle" + id2 + ";" + id3 + ";" + id1;
        } else {
            //logger.debug("KEYErrorAngle:Unknown angle key in pSet: " +id2 + " ; " + id3 + " ; " + id1+" take default angle:"+DEFAULT_ANGLE);
            return -1;
        }
        return ((Double) (pSet.get(akey).get(0))).doubleValue();
    }
901932
public static double[] minusTimes(final double[] v1, final double[] v2, final double s2) {
    assert v1.length == v2.length : ERR_VEC_DIMENSIONS;
    final double[] sub = new double[v1.length];
    for(int i = 0; i < v1.length; i++) {
      sub[i] = v1[i] - v2[i] * s2;
    }
    return sub;
  }
92179
public static double[] minus(final double[] v1, final double[] v2) {
    assert v1.length == v2.length : ERR_VEC_DIMENSIONS;
    final double[] sub = new double[v1.length];
    for(int i = 0; i < v1.length; i++) {
      sub[i] = v1[i] - v2[i];
    }
    return sub;
  }
247028
public float angleCos(Vector3fc v) {
        double length1Squared = x * x + y * y + z * z;
        double length2Squared = v.x() * v.x() + v.y() * v.y() + v.z() * v.z();
        double dot = x * v.x() + y * v.y() + z * v.z();
        return (float) (dot / (Math.sqrt(length1Squared * length2Squared)));
    }
772020
public static double mul(float v1, float v2) {
		return mul(Float.toString(v1), Float.toString(v2)).doubleValue();
	}
462846
public static double transposeTimes(final double[] v1, final double[] v2) {
    assert v2.length == v1.length : ERR_VEC_DIMENSIONS;
    double s = 0;
    for(int k = 0; k < v1.length; k++) {
      s += v1[k] * v2[k];
    }
    return s;
  }
360081
public static double dotSparse(SparseNumberVector v1, SparseNumberVector v2) {
    double dot = 0.;
    int i1 = v1.iter(), i2 = v2.iter();
    while(v1.iterValid(i1) && v2.iterValid(i2)) {
      final int d1 = v1.iterDim(i1), d2 = v2.iterDim(i2);
      if(d1 < d2) {
        i1 = v1.iterAdvance(i1);
      }
      else if(d2 < d1) {
        i2 = v2.iterAdvance(i2);
      }
      else { // d1 == d2
        dot += v1.iterDoubleValue(i1) * v2.iterDoubleValue(i2);
        i1 = v1.iterAdvance(i1);
        i2 = v2.iterAdvance(i2);
      }
    }
    return dot;
  }
993983
public static double add(Double v1, Double v2) {
		return add((Number) v1, (Number) v2).doubleValue();
	}
274775
public static double[] plusTimes(final double[] v1, final double[] v2, final double s2) {
    assert v1.length == v2.length : ERR_VEC_DIMENSIONS;
    final double[] result = new double[v1.length];
    for(int i = 0; i < result.length; i++) {
      result[i] = v1[i] + v2[i] * s2;
    }
    return result;
  }
1334992
@Override
  public double distance(NumberVector v1, NumberVector v2) {
    if(v1.getDimensionality() != v2.getDimensionality()) {
      throw new IllegalArgumentException("Different dimensionality of FeatureVectors\n  " + "first argument: " + v1 + "\n  " + "second argument: " + v2);
    }

    double sqrDist = 0;
    for(int d = BitsUtil.nextSetBit(dimensions, 0); d >= 0; d = BitsUtil.nextSetBit(dimensions, d + 1)) {
      final double delta = v1.doubleValue(d) - v2.doubleValue(d);
      sqrDist += delta * delta;
    }
    return FastMath.sqrt(sqrDist);
  }
392004
public static double cosAngle(NumberVector v1, NumberVector v2) {
    // Java Hotspot appears to optimize these better than if-then-else:
    return v1 instanceof SparseNumberVector ? //
        v2 instanceof SparseNumberVector ? //
            angleSparse((SparseNumberVector) v1, (SparseNumberVector) v2) : //
            angleSparseDense((SparseNumberVector) v1, v2) : //
        v2 instanceof SparseNumberVector ? //
            angleSparseDense((SparseNumberVector) v2, v1) : //
            angleDense(v1, v2);
  }
686251
double cosine(SparseVector vec1, SparseVector vec2)
    {
        double norm1 = vec1.norm();
        double norm2 = vec2.norm();
        double result = 0.0f;
        if (norm1 == 0 && norm2 == 0)
        {
            return result;
        }
        else
        {
            double prod = inner_product(vec1, vec2);
            result = prod / (norm1 * norm2);
            return Double.isNaN(result) ? 0.0f : result;
        }
    }
45133
def new_get_angle_diff(v1,v2):
    """"""
    v1 = numpy.array(v1)
    v2 = numpy.array(v2)
    angle = numpy.arctan2(numpy.linalg.norm(numpy.cross(v1, v2)), numpy.dot(v1, v2))
    return math.degrees(angle)
602084
static public <D extends ImageGray<D>>
	void direction2( D derivX , D derivY , GrayF32 angle )
	{
		if( derivX instanceof GrayF32) {
			GradientToEdgeFeatures.direction2((GrayF32)derivX,(GrayF32)derivY,angle);
		} else if( derivX instanceof GrayS16) {
			GradientToEdgeFeatures.direction2((GrayS16)derivX,(GrayS16)derivY,angle);
		} else if( derivX instanceof GrayS32) {
			GradientToEdgeFeatures.direction2((GrayS32)derivX,(GrayS32)derivY,angle);
		} else {
			throw new IllegalArgumentException("Unknown input type");
		}
	}
906032
def angle(self, center1_x, center1_y, center2_x, center2_y):
        
        phi_G = np.arctan2(center2_y - center1_y, center2_x - center1_x)
        return phi_G