Here you can find the source of dist14(double d12, double d23, double d34, double theta123, double theta234, double phi)
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 |
public static double dist14(double d12, double d23, double d34, double theta123, double theta234, double phi)
//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)); } }