Java Angle Between AngleBetweenVectors(double X1, double Y1, double Z1, double X2, double Y2, double Z2)

Here you can find the source of AngleBetweenVectors(double X1, double Y1, double Z1, double X2, double Y2, double Z2)

Description

Angle Between Vectors

License

Open Source License

Declaration

public static double AngleBetweenVectors(double X1, double Y1, double Z1, double X2, double Y2, double Z2) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static double AngleBetweenVectors(double X1, double Y1, double Z1, double X2, double Y2, double Z2) {
        // dot product calculation
        double dotproduct = vectorDotProduct(X1, Y1, Z1, X2, Y2, Z2);

        // absolute values of vectors
        double absoluteFirst = vectorAbsoluteValue(X1, Y1, Z1);
        double absoluteSecond = vectorAbsoluteValue(X2, Y2, Z2);

        double angleResult = Math.acos(dotproduct / (absoluteFirst * absoluteSecond));

        return angleResult;
    }/*from www .  ja va  2 s  .co m*/

    public static double vectorDotProduct(double X1, double Y1, double Z1, double X2, double Y2, double Z2) {
        double dorProduct = X1 * X2 + Y1 * Y2 + Z1 * Z2;

        return dorProduct;
    }

    public static double vectorAbsoluteValue(double X, double Y, double Z) {
        double absoluteValue = Math.sqrt(Math.pow(X, 2) + Math.pow(Y, 2) + Math.pow(Z, 2));

        return absoluteValue;
    }
}

Related

  1. angleBetween(final double ax, final double ay, final double bx, final double by)
  2. angleBetween2Lines(double l1x1, double l1y1, double l1x2, double l1y2, double l2x1, double l2y1, double l2x2, double l2y2)
  3. angleBetween2LinesVectorAlgebra(double x11, double y11, double x12, double y12, double x21, double y21, double x22, double y22)
  4. AngleBetweenDegrees(double longitudeFirstBody, double latitudeFirstBody, double longitudeSecondBody, double latitudeSecondBody)
  5. angleBetweenPoints(double ax, double ay, double bx, double by)