@@ -0,0 +1,1804 @@
+public class Geom3D %7B%0A  // distance from point (x, y, z) to plane aX + bY + cZ + d = 0%0A  public static double ptPlaneDist(double x, double y, double z,%0A      double a, double b, double c, double d) %7B%0A    return Math.abs(a*x + b*y + c*z + d) / Math.sqrt(a*a + b*b + c*c);%0A  %7D%0A  %0A  // distance between parallel planes aX + bY + cZ + d1 = 0 and%0A  // aX + bY + cZ + d2 = 0%0A  public static double planePlaneDist(double a, double b, double c,%0A      double d1, double d2) %7B%0A    return Math.abs(d1 - d2) / Math.sqrt(a*a + b*b + c*c);%0A  %7D%0A  %0A  // distance from point (px, py, pz) to line (x1, y1, z1)-(x2, y2, z2)%0A  // (or ray, or segment; in the case of the ray, the endpoint is the%0A  // first point)%0A  public static final int LINE = 0;%0A  public static final int SEGMENT = 1;%0A  public static final int RAY = 2;%0A  public static double ptLineDistSq(double x1, double y1, double z1,%0A      double x2, double y2, double z2, double px, double py, double pz,%0A      int type) %7B%0A    double pd2 = (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) + (z1-z2)*(z1-z2);%0A    %0A    double x, y, z;%0A    if (pd2 == 0) %7B%0A      x = x1;%0A      y = y1;%0A      z = z1;%0A    %7D else %7B%0A      double u = ((px-x1)*(x2-x1) + (py-y1)*(y2-y1) + (pz-z1)*(z2-z1)) / pd2;%0A      x = x1 + u * (x2 - x1);%0A      y = y1 + u * (y2 - y1);%0A      z = z1 + u * (z2 - z1);%0A      if (type != LINE && u %3C 0) %7B%0A        x = x1;%0A        y = y1;%0A        z = z1;%0A      %7D%0A      if (type == SEGMENT && u %3E 1.0) %7B%0A        x = x2;%0A        y = y2;%0A        z = z2;%0A      %7D%0A    %7D%0A    %0A    return (x-px)*(x-px) + (y-py)*(y-py) + (z-pz)*(z-pz);%0A  %7D%0A  %0A  public static double ptLineDist(double x1, double y1, double z1,%0A      double x2, double y2, double z2, double px, double py, double pz,%0A      int type) %7B%0A    return Math.sqrt(ptLineDistSq(x1, y1, z1, x2, y2, z2, px, py, pz, type));%0A  %7D%0A%7D%0A

Create Geom3D.java