コード例 #1
0
        /// <summary>
        /// Find the intersection of data with fix
        /// </summary>
        /// <param name="data"></param>
        /// <param name="fix"></param>
        /// <returns></returns>
        private static double getIntersection(LineP data, LineP fix)
        {
            Vector intersection = Vector.Interception(data.start, data.end, fix.start, fix.end);

            if (intersection != null)
            {
                return(Vector.Abs(intersection - data.start) / Vector.Abs(data.end - data.start));
            }
            return(-1);
        }
コード例 #2
0
        public static bool hasIntersections(List <Vector> list)
        {
            bool result = false;
            int  count  = list.Count;

            for (int i = 0; i < count; i++)
            {
                for (int j = 0; j < count; j++)
                {
                    if (i != j && ((i + 1) % count) != j && ((j + 1) % count) != i && ((j + 1) % count) != ((i + 1) % count))
                    {
                        if (Vector.Interception(list[i % count], list[(i + 1) % count], list[j % count], list[(j + 1) % count]) != null)
                        {
                            result = true;
                            break;
                        }
                    }
                }
            }
            return(result);
        }
コード例 #3
0
        /// <summary>
        /// Find the intersection of data with fix. Insersection point ip is output parameter
        /// </summary>
        /// <param name="data"></param>
        /// <param name="fix"></param>
        /// <param name="ip"></param>
        /// <returns></returns>
        private static bool getIntersection(LineP data, LineP fix, out IntersectionPoint ip)
        {
            ip = new IntersectionPoint();
            bool   res           = false;
            Vector intersectionV = Vector.Interception(data.start, data.end, fix.start, fix.end);

            if (intersectionV != null)
            {
                double intersection = Vector.Abs(intersectionV - data.start) / Vector.Abs(data.end - data.start);
                long   timestmp     = data.TimestamStart + (long)Math.Truncate((data.TimestamEnd - data.TimestamStart) * intersection);
                double x            = data.start.X + (data.end.X - data.start.X) * intersection;
                double y            = data.start.Y + (data.end.Y - data.start.Y) * intersection;
                double z            = data.start.Z + (data.end.Z - data.start.Z) * intersection;
                ip.longitude = x;
                ip.latitude  = y;
                ip.altitude  = z;
                ip.Timestamp = timestmp;
                res          = true;
                return(res);
            }
            return(res);
        }