Пример #1
0
        /// <summary>
        /// Connects two given circles by a clothoid function and returns it's points.
        /// This node throws errors if both circles are intersecting or too far away from each other.
        /// </summary>
        /// <param name="circleStart">Circle to start from</param>
        /// <param name="circleEnd">Circle to connect to</param>
        /// <param name="stepsize">Stepsize for points returned along the clothoid</param>
        /// <param name="tolerance">Clothoid generation tolerance</param>
        /// <returns>Points along a Clothoid function</returns>
        public static IEnumerable <Point> ByCircleAndCircle(Circle circleStart, Circle circleEnd, double stepsize, double tolerance = 0.0)
        {
            Clolib.Geometry.Circle   cCircleStart = circleStart.ToCGeo();
            Clolib.Geometry.Circle   cCircleEnd   = circleEnd.ToCGeo();
            Clolib.Geometry.Clothoid clothoid     = new Clolib.Geometry.Clothoid();

            int result = Clolib.Geometry.Clothoid.Connect(cCircleStart, cCircleEnd, tolerance, out clothoid);

            switch (result)
            {
            case -1:
                throw new Exception("Circle and Circle are intersecting.");

            case 1:
                throw new Exception("Connecting clothoid becomes too long.");
            }

            List <Point> points = new List <Point>();

            foreach (var point in clothoid.GetPoints(stepsize, true))
            {
                points.Add(point.ToAGeo());
            }
            return(points);
        }
Пример #2
0
        /// <summary>
        /// Creates a new Clothoid function and returns it's points.
        /// </summary>
        /// <param name="origin">Origin</param>
        /// <param name="unitVector">Unit vector</param>
        /// <param name="curvatureRate">Curvature rate</param>
        /// <param name="startLength">Start length</param>
        /// <param name="endLength">End length</param>
        /// <param name="stepsize">Stepsize for points returned along the clothoid</param>
        /// <returns>Points along a Clothoid function</returns>
        public static IEnumerable <Point> ByParameters(Point origin, Vector unitVector, double curvatureRate, double startLength, double endLength, double stepsize)
        {
            Clolib.Geometry.Clothoid clothoid = new Clolib.Geometry.Clothoid(curvatureRate, origin.ToCGeo(), unitVector.ToCGeo(), startLength, endLength);

            List <Point> points = new List <Point>();

            foreach (var point in clothoid.GetPoints(stepsize, true))
            {
                points.Add(point.ToAGeo());
            }
            return(points);
        }