79 lines
1.7 KiB
C#
79 lines
1.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace CampusAppWPortalLib8.Model.Utility
|
|
{
|
|
public class MapPoint : IEquatable<MapPoint>
|
|
{
|
|
|
|
#region Constructor
|
|
|
|
public MapPoint(double x, double y)
|
|
{
|
|
this.X = x;
|
|
this.Y = y;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region property
|
|
|
|
public double X { get; set; }
|
|
|
|
public double Y { get; set; }
|
|
|
|
#endregion
|
|
|
|
#region method
|
|
|
|
public static MapPoint operator +(MapPoint mp1, MapPoint mp2)
|
|
{
|
|
return new MapPoint(mp1.X + mp2.X, mp1.Y + mp2.Y);
|
|
}
|
|
|
|
public static MapPoint operator -(MapPoint mp1, MapPoint mp2)
|
|
{
|
|
return new MapPoint(mp1.X - mp2.X, mp1.Y - mp2.Y);
|
|
}
|
|
|
|
public static MapPoint operator -(MapPoint mp1)
|
|
{
|
|
return new MapPoint(-mp1.X, -mp1.Y);
|
|
}
|
|
|
|
public static MapPoint operator *(MapPoint mp1, MapPoint mp2)
|
|
{
|
|
return new MapPoint(mp1.X * mp2.X, mp1.Y * mp2.Y);
|
|
}
|
|
|
|
public static MapPoint operator /(MapPoint mp1, MapPoint mp2)
|
|
{
|
|
return new MapPoint(mp1.X / mp2.X, mp1.Y / mp2.Y);
|
|
}
|
|
|
|
public bool Equals(MapPoint other)
|
|
{
|
|
if (other != null && this.X == other.X && this.Y == other.Y)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
|
|
public static double CalcDistance(MapPoint src, MapPoint dst)
|
|
{
|
|
MapPoint subPoint = dst - src;
|
|
subPoint *= subPoint;
|
|
double result = Math.Sqrt(subPoint.X + subPoint.Y);
|
|
return result;
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|