/// <summary>
 /// Calculates arc distance after projection onto standard sphere
 /// </summary>
 /// <param name="er"></param>
 /// <returns>Distance</returns>
 public override double DistanceTo(ElectrodeRecord er)
 {
     if (!(er is XYZRecord))
         throw new Exception("In XYZRecord.DistanceTo: incompatable ElectrodeRecord types");
     XYZRecord xyz = (XYZRecord)er;
     double r1 = Math.Sqrt(X * X + Y * Y + Z * Z);
     double r2 = Math.Sqrt(xyz.X * xyz.X + xyz.Y * xyz.Y + xyz.Z * xyz.Z);
     double chord = Math.Sqrt(Math.Pow(X / r1 - xyz.X / r2, 2) +
         Math.Pow(Y / r1 - xyz.Y / r2, 2) + Math.Pow(Z / r1 - xyz.Z / r2, 2));
     return 2D * radius * Math.Asin(chord / 2D);
 }
 public override double DistanceTo(ElectrodeRecord er)
 {
     if (!(er is PhiThetaRecord))
     {
         throw new Exception("In PhiThetaRecord.DistanceTo: incompatable ElectrodeRecord types");
     }
     return angleDiff(this.Phi, this.Theta, ((PhiThetaRecord)er).Phi, ((PhiThetaRecord)er).Theta);
 }
 public override double DistanceTo(ElectrodeRecord er)
 {
     if(!(er is XYRecord))
         throw new Exception("In XYRecord.DistanceTo: incompatable ElectrodeRecord types");
     XYRecord xy = (XYRecord)er;
     double phi1 = Math.Sqrt(X * X + Y * Y);
     double phi2 = Math.Sqrt(xy.X * xy.X + xy.Y * xy.Y);
     double theta1 = Math.Atan2(X, Y);
     double theta2 = Math.Atan2(xy.X, xy.Y);
     return angleDiff(phi1, theta1, phi1, theta2);
 }
 //a sphere of standard radius
 public abstract double DistanceTo(ElectrodeRecord er);