Java Angle Between angleBetween2LinesVectorAlgebra(double x11, double y11, double x12, double y12, double x21, double y21, double x22, double y22)

Here you can find the source of angleBetween2LinesVectorAlgebra(double x11, double y11, double x12, double y12, double x21, double y21, double x22, double y22)

Description

angle Between Lines Vector Algebra

License

Apache License

Declaration

public static double angleBetween2LinesVectorAlgebra(double x11, double y11, double x12, double y12, double x21,
            double y21, double x22, double y22) 

Method Source Code

//package com.java2s;
/*//  w  w w . j a  v  a 2s .co m
 * Beigesoft ?
 * 
 * Licensed under the Apache License, Version 2.0
 * 
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 */

public class Main {
    public static double angleBetween2LinesVectorAlgebra(double x11, double y11, double x12, double y12, double x21,
            double y21, double x22, double y22) {
        /*
         * U(u1,u2) - vector line1
         * V(v1,v2) - vector line2
         * cosa = abs(u1*v1+u2*v2)/sqrt((u1*u1+u2*u2)*(v1*v1+v2*v2))
         */
        double[] u = { x12 - x11, y12 - y11 };
        double[] v = { x22 - x21, y22 - y21 };
        double cosa = Math.abs(u[0] * v[0] + u[1] * v[1])
                / Math.sqrt((u[0] * u[0] + u[1] * u[1]) * (v[0] * v[0] + v[1] * v[1]));
        return Math.acos(cosa);
    }
}

Related

  1. angle2DBetween(double[] coord1, double[] coord2)
  2. angle_between(double x1, double y1, double z1, double x2, double y2, double z2)
  3. angleBetween(double[] v1, double[] v2)
  4. angleBetween(final double ax, final double ay, final double bx, final double by)
  5. angleBetween2Lines(double l1x1, double l1y1, double l1x2, double l1y2, double l2x1, double l2y1, double l2x2, double l2y2)
  6. AngleBetweenDegrees(double longitudeFirstBody, double latitudeFirstBody, double longitudeSecondBody, double latitudeSecondBody)
  7. angleBetweenPoints(double ax, double ay, double bx, double by)
  8. AngleBetweenVectors(double X1, double Y1, double Z1, double X2, double Y2, double Z2)