Java cos cos(double[] v1, double[] v2)

Here you can find the source of cos(double[] v1, double[] v2)

Description

cos

License

Apache License

Declaration

public static double cos(double[] v1, double[] v2) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static double cos(double[] v1, double[] v2) {
        double s = 0;
        s = multiple(v1, v2);/*w  w w  .j av a  2  s. c  o  m*/
        double a = Math.pow(multiple(v1, v1) * multiple(v2, v2), 0.5);
        return s / a;
    }

    public static double multiple(double[] v1, double[] v2) {
        double v = 0;
        for (int i = 0; i < v1.length; i++) {
            v = v + v1[i] * v2[i];
        }
        return v;
    }
}

Related

  1. cos(double a)
  2. cos(double anAngle)
  3. cos(double d)
  4. cos(double radians)
  5. cos(double[] v1, double[] v2)
  6. cos(final double value)
  7. cos(final float angle)
  8. cos(final float value)
  9. cos(float angle)