⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mathtools.cs

📁 两种AstarPathFinder 一种DijkstraPathfinder BFS
💻 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 + -