コード例 #1
0
        private LineSeries WindowCrossings(OneForm xOneForm, int length)
        {
            var allCrossings            = new List <Tuple <double, double> >();
            var windowEnteringCrossings = new List <Tuple <double, double> >();

            foreach (var constraint in Constraints)
            {
                allCrossings.Add(Intersection(xOneForm, length, constraint));
            }
            foreach (var pt in allCrossings)
            {
                if (Constraints.Any(c => c.Violate(pt)))
                {
                    continue;
                }
                windowEnteringCrossings.Add(pt);
            }
            var lineSeries = new LineSeries()
            {
                LineStyle       = (length == 0 ? LineStyle.Solid : LineStyle.Dash),
                Color           = (length == 0 ? OxyColors.Black : OxyColors.Gray),
                StrokeThickness = (length == 0 ? 2 : 0.5)
            };

            windowEnteringCrossings.ForEach(c => lineSeries.Points.Add(new DataPoint(c.Item1, c.Item2)));
            return(lineSeries);
        }
コード例 #2
0
        private Tuple <double, double> Intersection(OneForm o, int z, Constraint c)
        {
            // intersection betwen the line normal to a vector from the origin to point and the constraint
            var y = o.X * c.Length * c.Length - c.X * z;

            y /= (o.X * c.Y - c.X * o.Y);
            var x = (z - o.Y * y) / o.X;

            return(new Tuple <double, double>(x, y));
        }
コード例 #3
0
        /// <summary>
        /// Returns lines associated with the supplied 1-form
        /// </summary>
        /// <param name="oneForm"></param>
        /// <returns></returns>
        public IEnumerable <LineSeries> Lines(OneForm oneForm)
        {
            yield return(WindowCrossings(oneForm, 0));

            var length = 1;

            while (EntersWindow(oneForm, length))
            {
                yield return(WindowCrossings(oneForm, length++));
            }
            length = -1;
            while (EntersWindow(oneForm, length))
            {
                yield return(WindowCrossings(oneForm, length--));
            }
        }
コード例 #4
0
        private bool EntersWindow(OneForm xOneForm, int length)
        {
            var entersWindow = false;

            foreach (var constraint in Constraints)
            {
                var  intersection = Intersection(xOneForm, length, constraint);
                bool outside      = false;
                foreach (var c in Constraints)
                {
                    if (c.Violate(intersection))
                    {
                        outside = true;
                    }
                }
                if (outside == false)
                {
                    entersWindow = true;
                }
            }
            return(entersWindow);
        }
コード例 #5
0
 private LineSeries WindowCrossings(OneForm xOneForm, int length)
 {
     var allCrossings = new List<Tuple<double, double>>();
     var windowEnteringCrossings = new List<Tuple<double, double>>();
     foreach (var constraint in Constraints)
     {
         allCrossings.Add(Intersection(xOneForm, length, constraint));
     }
     foreach(var pt in allCrossings)
     {
         if (Constraints.Any(c => c.Violate(pt))) continue;
         windowEnteringCrossings.Add(pt);
     }
     var lineSeries = new LineSeries()
     {
         LineStyle = (length == 0 ? LineStyle.Solid : LineStyle.Dash),
         Color = (length == 0 ? OxyColors.Black : OxyColors.Gray),
         StrokeThickness = (length == 0 ? 2 : 0.5)
     };
     windowEnteringCrossings.ForEach(c => lineSeries.Points.Add(new DataPoint(c.Item1, c.Item2)));
     return lineSeries;
 }
コード例 #6
0
 private Tuple<double, double> Intersection(OneForm o, int z, Constraint c)
 {
     // intersection betwen the line normal to a vector from the origin to point and the constraint
     var y = o.X * c.Length * c.Length - c.X * z;
     y /= (o.X * c.Y - c.X * o.Y);
     var x = (z - o.Y * y ) / o.X;
     return new Tuple<double, double>(x, y);
 }
コード例 #7
0
 private Tuple<double, double> Increment(OneForm xOneForm, Tuple<double, double> point)
 {
     return new Tuple<double, double>(point.Item1 + xOneForm.UnitVector[0], point.Item2 + xOneForm.UnitVector[1]);
 }
コード例 #8
0
 private bool EntersWindow(OneForm xOneForm, int length)
 {
     var entersWindow = false;
     foreach (var constraint in Constraints)
     {
         var intersection = Intersection(xOneForm, length, constraint);
         bool outside = false;
         foreach(var c in Constraints)
         {
             if (c.Violate(intersection))
                 outside = true;
         }
         if (outside == false) entersWindow = true;
     }
     return entersWindow;
 }
コード例 #9
0
 /// <summary>
 /// Returns lines associated with the supplied 1-form
 /// </summary>
 /// <param name="oneForm"></param>
 /// <returns></returns>
 public IEnumerable<LineSeries> Lines(OneForm oneForm)
 {
     yield return WindowCrossings(oneForm, 0);
     var length = 1;
     while(EntersWindow(oneForm, length))
     {
         yield return WindowCrossings(oneForm, length++);
     }
     length = -1;
     while (EntersWindow(oneForm, length))
     {
         yield return WindowCrossings(oneForm, length--);
     }
 }
コード例 #10
0
 private Tuple <double, double> Increment(OneForm xOneForm, Tuple <double, double> point)
 {
     return(new Tuple <double, double>(point.Item1 + xOneForm.UnitVector[0], point.Item2 + xOneForm.UnitVector[1]));
 }