コード例 #1
0
 private double calcCrossProduct(LocationMark origin, LocationMark p2)
 {
     return((p2.Latitude - origin.Latitude) * (this.Longitude - origin.Longitude)
            - (p2.Longitude - origin.Longitude) * (this.Latitude - origin.Latitude));
 }
コード例 #2
0
 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)));
 }
コード例 #3
0
 public bool IsLeftOfLine(LocationMark from, LocationMark to)
 {
     return(calcCrossProduct(from, to).CompareTo(0) > 0);
 }