本文整理汇总了C#中Landis.SpatialModeling.Site.GetNeighbor方法的典型用法代码示例。如果您正苦于以下问题:C# Site.GetNeighbor方法的具体用法?C# Site.GetNeighbor怎么用?C# Site.GetNeighbor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Landis.SpatialModeling.Site
的用法示例。
在下文中一共展示了Site.GetNeighbor方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetNeighbors
//---------------------------------------------------------------------
private List<Site> GetNeighbors(Site site,
int windDirection,
double windSpeed)
{
if (windDirection > 7)
windDirection = 7;
double[] windProbs =
{
(((4.0 - windSpeed)/8.0) * (1+windSpeed)), //Primary direction
(((4.0 - windSpeed)/8.0) * (1+windSpeed)),
(((4.0 - windSpeed)/8.0)),
(((4.0 - windSpeed)/8.0) * (1-windSpeed)),
(((4.0 - windSpeed)/8.0) * (1-windSpeed)), //Opposite of primary direction
(((4.0 - windSpeed)/8.0) * (1-windSpeed)),
(((4.0 - windSpeed)/8.0)),
(((4.0 - windSpeed)/8.0) * (1+windSpeed)),
};
double windProb = 0.0;
int index = 0;
int success = 0;
List<Site> neighbors = new List<Site>(9);
foreach (RelativeLocation relativeLoc in neighborhood)
{
Site neighbor = site.GetNeighbor(relativeLoc);
if (index + windDirection > 7)
windProb = windProbs[index + windDirection - 8];
else
windProb = windProbs[index + windDirection];
if (neighbor != null
&& PlugIn.ModelCore.NextDouble() < windProb)
{
neighbors.Add(neighbor);
success++;
}
index++;
}
//Next, add the 9th neighbor, a neighbor one cell beyond the
//8 nearest neighbors.
//array index 0 = north; 1 = northeast, 2 = east,...,8 = northwest
int[] vertical ={2,2,0,-2,-2,-2,0,2};
int[] horizontal={0,2,2,2,0,-2,-2,-2};
RelativeLocation relativeLoc9 =
new RelativeLocation(vertical[windDirection], horizontal[windDirection]);
Site neighbor9 = site.GetNeighbor(relativeLoc9);
if (neighbor9 != null && PlugIn.ModelCore.GenerateUniform() < windSpeed)
neighbors.Add(neighbor9);
return neighbors;
}