Java Distance Calculate dist14(double d12, double d23, double d34, double theta123, double theta234, double phi)

Here you can find the source of dist14(double d12, double d23, double d34, double theta123, double theta234, double phi)

Description

Computes the 1-4 distance in an arbitrary (nonplanar) quadrangle, given d12, d13, d14, theta123 = angle(1,2,3), theta234 = angle(2,3,4) and phi = angle(plane(1,2,3), plane(2,3,4)).

License

Open Source License

Parameter

Parameter Description
theta123 the angle between 1,2,3 in radians.
theta234 the angle between 2,3,4 in radians.
phi the angle between the planes (1,2,3) and (2,3,4), in radians

Return

d14

Declaration

public static double dist14(double d12, double d23, double d34, double theta123, double theta234, double phi) 

Method Source Code

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

public class Main {
    /**/*  w  w w  . j a  v  a2s  . c  o m*/
    Computes the 1-4 distance in an arbitrary (nonplanar) quadrangle,
    given d12, d13, d14, theta123 = angle(1,2,3), theta234 = angle(2,3,4)
    and phi = angle(plane(1,2,3), plane(2,3,4)).
    @param theta123 the angle between 1,2,3 in radians.
    @param theta234 the angle between 2,3,4 in radians.
    @param phi the angle between the planes (1,2,3) and (2,3,4), in radians
    @return d14
     */
    public static double dist14(double d12, double d23, double d34, double theta123, double theta234, double phi) {
        double alpha123 = Math.PI - theta123;
        double alpha234 = Math.PI - theta234;
        double a1 = Math.cos(alpha123) * d12;
        double a2 = Math.sin(alpha123) * d12;
        double b1 = Math.cos(alpha234) * d34;
        double b2 = Math.sin(alpha234) * d34;
        double c = a1 + d23 + b1;
        double e_sq = cosineTheorem(a2, b2, phi);
        return (Math.sqrt(c * c + e_sq));
    }

    /**
    For a planar triangle 1,2,3, computes d13, based on d12,d23 and
    theta23 = angle(d12,d23) using the cosine theorem, i.e.:
    d13^2 = d12^2 + d23^2 + d12 d23 cos(theta23)
    @param theta23 the angle between d12, d23 in radians.
    @return c^2 (not c !!!!)
     */
    public static double cosineTheorem(double d12, double d23, double theta123) {
        return (d12 * d12 + d23 * d23 - 2 * d12 * d23 * Math.cos(theta123));
    }
}

Related

  1. dist(float x1, float y1, float x2, float y2, float xp, float yp)
  2. dist(float x1, float y1, float z1, float x2, float y2, float z2)
  3. dist(int i, int j, int width)
  4. dist(int p1, int p2)
  5. dist(int x1, int y1, int x2, int y2)
  6. dist2Degrees(double dist, double radius)
  7. dist2Radians(double dist, double radius)
  8. distAlongRaySquared(double px, double py, double qx, double qy, double rx, double ry)
  9. distance(double lat1, double lng1, double lat2, double lng2)