Пример #1
0
        public double DistancePointToVector(Point v1, Point v2)
        {
            Vector AB = v2 - v1;
            Vector AP = this - v1;

            IdaComPoint2D v12 = new IdaComPoint2D(AB.X, AB.Y);
            IdaComPoint2D v1p = new IdaComPoint2D(AP.X, AP.Y);

            //AB nesmi byt nulovy vektor, ten by vsak nedefinoval primku
            double t = (v12 | v1p) / (v12 | v12);

            // to je ten kyzeny bod na primce AB
            IdaComPoint2D K = v1 + v12 * t;

            double Dist = VectorLength(K, this);

            //vzdalenost prominuteho bodu K na primky AB od bodu A
            double Dist1 = VectorLength(K, v1);

            //vzdalenost prominuteho bodu K na primky AB od bodu B
            double Dist2 = VectorLength(K, v2);

            //delka usecky AB
            double Dist3 = VectorLength(v1, v2);

            //vzdalenost vlozky od zacatku usecky
            double Dist4 = VectorLength(this, v1);

            //vzdalenost vlozky od konce usecky
            double Dist5 = VectorLength(this, v2);

            //v pripade, ze soucet  Dist1+Dis2 je roven Dist3 potom bod lezi mezi
            //body AB a nejkrati vzdalenost je Dist, v opacnem pripade je to jedna
            //ze vzdalenosti Dist4 nebo Dist5
            if ((Dist3 - Dist2 - Dist1).IsZero())
            {
                return(Dist);
            }
            else
            {
                if (Dist4 > Dist5)
                {
                    return(Dist5);
                }
                else
                {
                    return(Dist4);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// projection point to vector direction
        /// </summary>
        /// <param name="point">point</param>
        /// <param name="nDir">direction of projection</param>
        /// <returns>length of projection</returns>
        public static double Projection(Point point, IdaComPoint2D nDir)
        {
            double projection = point | nDir;

            return(projection);
        }
Пример #3
0
        /// <summary>
        /// projection point to vector direction
        /// </summary>
        /// <param name="nDir">direction of projection</param>
        /// <returns>length of projection</returns>
        public double Projection(IdaComPoint2D nDir)
        {
            double projection = this | nDir;

            return(projection);
        }