PointExtensions.cs 1.36 KB
using RCS.Model.Comm;
using RCS.Model.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace RCS.WinClient.Common
{
    public static class PointExtensions
    {
        public static bool IsHomePoint(this Base_Point point, Base_Agv agv)
        {
            return
             point.IsStop
                || agv.AgvType == EnumMsg.AgvType.差速
                && point.PointType.In(EnumMsg.PointType.回家点, EnumMsg.PointType.站台点)
                && !point.Barcode.In("2404", "2904")
                && !App.StationList.Any(x=>x.Barcode==point.Barcode&&( x.Name.StartsWith("A02")||x.Name.In("A0101","A0102")));

        }



        /// <summary>
        /// 判断点是否在线段上
        /// </summary>
        /// <param name="A">线段端点</param>
        /// <param name="B">线段端点</param>
        /// <param name="P">判断点</param>
        /// <param name="tolerance">误差</param>
        /// <returns></returns>
        public static bool IsOnLineSegment(this Base_Point P, Base_Point A, Base_Point B, double tolerance = 5)
        {
            var distance = ComnMethod.GetPointDistanceToLineSegment(A, B, P);
            // 判断距离是否在误差范围内
            return distance <= tolerance;
        }


    }
}