Here you can find the source of AngleBetweenVectors(double X1, double Y1, double Z1, double X2, double Y2, double Z2)
public static double AngleBetweenVectors(double X1, double Y1, double Z1, double X2, double Y2, double Z2)
//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; } }