// Distance computes the distance from this FieldPoint to point p. public double Distance(FieldPoint p) { double x = (p.X - X); double y = (p.Y - Y); double z = (p.Z - Z); return Math.Sqrt(x * x + y * y + z * z); }
// Angle computes the angel between left, right, and p, with p the // vertext of the angle. public double Angle(FieldPoint left, FieldPoint right, FieldPoint p) { double b = right.Distance(p); double a = left.Distance(p); double width = right.Distance(left); double C = Math.Acos((a * a + b * b - width * width) / (2 * a * b)); // C = C * 180.0 / PI; // convert to degrees return C; }