• p点到(a,b)点两所在直线的垂点坐标及该点是否在直线上


    public class LonLatCalibration
        {
            //已知两点(x1,y1) , (x2,y2)
            //代入两点公式: (x-x1)/(x2-x1)=(y-y1)/(y2-y1)
            //直线方程的公式有以下几种:
            //斜截式:y=kx+b
            //截距式:x/a+y/b=1
            //两点式:(x-x1)/(x2-x1)=(y-y1)/(y2-y1)
            //一般式:ax+by+c=0
            //只要知道两点坐标,代入任何一种公式,都可以求出直线的方程。
            //设直线方程为ax+by+c=0,点坐标为(m,n)   
            //则垂足为((b*b*m-a*b*n-a*c)/(a*a+b*b),(a*a*n-a*b*m-b*c)/(a*a+b*b))
            /// <summary>
            /// p点到(a,b)点两所在直线的垂点坐标
            /// </summary>
            /// <param name="a"></param>
            /// <param name="b"></param>
            /// <param name="p"></param>
            /// <returns></returns>
            public static Vector GetFoot(Vector a, Vector b, Vector p)
            {
                double fa = b.y - a.y;
                double fb = a.x - b.x;
                double fc = a.y * b.x - a.x * b.y;
                Vector foot = new Vector();//垂足
                foot.x = (fb * fb * p.x - fa * fb * p.y - fa * fc) / (fa * fa + fb * fb);
                foot.y = (fa * fa * p.y - fa * fb * p.x - fb * fc) / (fa * fa + fb * fb);
                return foot;
            }
            /// <summary>
            /// p点是否在(a,b)两点所在直线上
            /// </summary>
            /// <param name="a"></param>
            /// <param name="b"></param>
            /// <param name="foot"></param>
            /// <returns></returns>
            public static bool DotIsOnLine(Vector a, Vector b, Vector foot)
            {
                return Math.Min(a.x, b.x) <= foot.x && foot.x <= Math.Max(a.x, b.x) && Math.Min(a.y, b.y) <= foot.y && foot.y <= Math.Max(a.y, b.y);
            }
        }
        public class Vector
        {
            public double x;
            public double y;
            public override string ToString()
            {
                return string.Format("{0},{1}", x, y);
            }
        }

    地图验证:WebApplication1.rar 

  • 相关阅读:
    OGG_GoldenGate数据控制进程Manager(案例)
    OGG_GoldenGate安装和环境搭建(案例)
    OGG_Oracle GoldenGate简介(概念)
    DBA_Oracle Erp R12系统文件结构(概念)
    PLSQL_统计信息系列10_统计信息过旧导致程序出现性能问题
    PLSQL_统计信息系列09_统计信息在不同数据库中迁移
    Hadoop2源码分析-准备篇
    高可用Hadoop平台-答疑篇
    高可用Hadoop平台-实战尾声篇
    高可用Hadoop平台-实战
  • 原文地址:https://www.cnblogs.com/94cool/p/2738996.html
Copyright © 2020-2023  润新知