public static FactorFormula ExponentialAttenuation(SpotEntity spot)
 {
     return(p =>
     {
         double d = spot.GetDistTo(p);
         return Math.Pow(spot.Coefficient, 1 - d / spot.ServingRadius);
     });
 }
 public static FactorFormula LinearToZeroInRadius(SpotEntity spot)
 {
     return(p =>
     {
         double d = spot.GetDistTo(p);
         return (d > spot.ServingRadius) ? 0 : spot.Coefficient *(1 - d / spot.ServingRadius);
     });
 }
 public static FactorFormula ZeroOne(SpotEntity spot)
 {
     return(p =>
     {
         double d = spot.GetDistTo(p);
         return (d > spot.ServingRadius) ? 0 : spot.Coefficient;
     });
 }
Ejemplo n.º 4
0
        public static SpotEntity addspot(double x, double y)
        {
            var spot = new SpotEntity {
                Position = new Geometry.Point2D(x, y)
            };

            city.CitySpots.Add(spot);
            return(spot);
        }
Ejemplo n.º 5
0
        public void AddSpot(CityEntityType type, Point2D pos)
        {
            SpotEntity spot = new SpotEntity(type);

            spot.Position      = pos;
            spot.ServingRadius = 600.0;
            spot.Coefficient   = 1200.0;

            _cityModel.CitySpots.Add(spot);
            _cityModel.Factors.Add(spot);
        }
 public static FactorFormula InverseSquare(SpotEntity spot, double maxValue = double.MaxValue)
 {
     return(p =>
     {
         double d = spot.GetDistTo(p);
         double v = spot.Coefficient / d / d;
         if (v > 0)
         {
             return v > maxValue ? maxValue : v;
         }
         else
         {
             return v < -maxValue ? -maxValue : v;
         }
     });
 }
Ejemplo n.º 7
0
 public override void MouseHoverHandler(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left) // Take care: this happens before MouseClick
     {
         // Move spot
         if (_hover != null)
         {
             Viewer.Current.Canvas.Cursor = Cursors.Hand;
             _hover.Position = DisplayManager.Current.CityCoordinate(e.X, e.Y);
             ValueBuffer.UpdateValues();
             Viewer.Current.Canvas.Invalidate();
         }
     }
     else if (e.Button == MouseButtons.None)
     {
         // Detect spot
         if (TaskPanel.Current.cbShowSpot.Checked)
         {
             SpotEntity temp = _hover;
             _hover = DisplayManager.Current.DetectSpotHover(e.X, e.Y);
             if (_hover != temp)
             {
                 Viewer.Current.Canvas.Invalidate();
             }
             if (_hover != null)
             {
                 Viewer.Current.Canvas.Cursor = Cursors.Hand;
             }
             else if (CanvasWindow.Current.IsDragging)
             {
                 Viewer.Current.Canvas.Cursor = Cursors.SizeAll;
             }
             else
             {
                 Viewer.Current.Canvas.Cursor = Cursors.Default;
             }
         }
     }
 }
Ejemplo n.º 8
0
 public void RemoveSpot(SpotEntity spot)
 {
     _cityModel.CitySpots.Remove(spot);
     _cityModel.Factors.Remove(_cityModel.Factors.Single(x => (x as SpotEntity).Properties == spot.Properties)); // 注意:这只是一个引用比较 mod 20110801
 }