private double calcCrossProduct(LocationMark origin, LocationMark p2) { return((p2.Latitude - origin.Latitude) * (this.Longitude - origin.Longitude) - (p2.Longitude - origin.Longitude) * (this.Latitude - origin.Latitude)); }
public double DistanceToLine(LocationMark a, LocationMark b) { return(Math.Abs((b.Longitude - a.Longitude) * (a.Latitude - this.Latitude) - (a.Longitude - this.Longitude) * (b.Latitude - a.Latitude)) / Math.Sqrt(Math.Pow(b.Longitude - a.Longitude, 2) + Math.Pow(b.Latitude - a.Latitude, 2))); }
public bool IsLeftOfLine(LocationMark from, LocationMark to) { return(calcCrossProduct(from, to).CompareTo(0) > 0); }