📄 mathtools.cs
字号:
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
namespace PathFinder
{
class MathTools
{
/// <summary>
/// 返回两点间的直线距离
/// </summary>
/// <param name="from">起点</param>
/// <param name="to">终点</param>
/// <returns>距离</returns>
static public double DirectDistance(Point from, Point to)
{
return System.Math.Pow((from.X - to.X) * (from.X - to.X) + (from.Y - to.Y) * (from.Y - to.Y), 0.5);
}
/// <summary>
/// 算平方的距离
/// </summary>
/// <param name="from"></param>
/// <param name="to"></param>
/// <returns></returns>
static public int SquareDistance(Point from, Point to)
{
return (from.X - to.X) * (from.X - to.X) + (from.Y - to.Y) * (from.Y - to.Y);
}
/// <summary>
/// 返回两点间的欧式几何距离
/// </summary>
/// <param name="from">起点</param>
/// <param name="to">终点</param>
/// <returns>距离</returns>
static public double MDistance(Point from, Point to)
{
return System.Math.Abs(from.X - to.X) + System.Math.Abs(from.Y - to.Y);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -