示例#1
0
 /// <summary>
 /// Calculate the distance between x,y and the datapoint.
 /// </summary>
 /// <param name="datapoint">The datapoint constituting the one end of the line.</param>
 /// <param name="x">The x-value of the other end of the line.</param>
 /// <param name="y">The y-value of the other end of the line.</param>
 /// <returns>The euclidean distance between the two points.</returns>
 private double GetDistance(HeatDatapoint datapoint, double x, double y)
 {
     if (_config.ManhattanDistance)
     {
         return(Math.Abs(datapoint.X - x) + Math.Abs(datapoint.Y - y));
     }
     else
     {
         return(Math.Sqrt(Math.Pow(datapoint.X - x, 2) + Math.Pow(datapoint.Y - y, 2)));
     }
 }
示例#2
0
 /// <summary>
 /// Gets the value of the datapoint according to the given tile center.
 /// </summary>
 /// <param name="x">The x-value of the center of the heat tile.</param>
 /// <param name="y">The y-value of the center of the heat tile.</param>
 /// <param name="datapoint">The datapoint to weight.</param>
 /// <returns>Either the actual value of the datapoint or the same weighted by the distance to the tile center.</returns>
 private double GetWeightedValue(double x, double y, HeatDatapoint datapoint)
 {
     if (_config.WeightByDistance)
     {
         // Weight datapoint value by the distance to the tiles center
         return((1.0 - GetDistance(datapoint, x, y) / Radius) * datapoint.GetValue(_config.DataIndex));
     }
     else
     {
         return(datapoint.GetValue(_config.DataIndex));
     }
 }