本文整理汇总了C#中Cluster.add_location方法的典型用法代码示例。如果您正苦于以下问题:C# Cluster.add_location方法的具体用法?C# Cluster.add_location怎么用?C# Cluster.add_location使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cluster
的用法示例。
在下文中一共展示了Cluster.add_location方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: calculate_location_test
public void calculate_location_test()
{
Location[] loc = new Location[4];
loc[0] = new Location(3, 2);
loc[1] = new Location(3, 3);
loc[2] = new Location(3, 4);
loc[3] = new Location(2, 3);
Cluster clust = new Cluster();
clust.add_location(loc[0]);
clust.add_location(loc[1]);
clust.add_location(loc[2]);
clust.add_location(loc[3]);
Location loc2 = clust.location;
Specify.That(loc2.x).ShouldEqual((float)11/4);
Specify.That(loc2.y).ShouldEqual((float)12/4);
}
示例2: cluster_add_location_test
public void cluster_add_location_test()
{
Cluster clust = new Cluster();
for (int i = 0; i < 5; i++)
{
Location loc = new Location(2, i);
clust.add_location(loc);
Specify.That(clust.locations[i].x).ShouldEqual(2);
Specify.That(clust.locations[i].y).ShouldEqual(i);
Specify.That(clust.locations[i].Equals(loc)).ShouldBeTrue();
}
}
示例3: convex_hull_test
public void convex_hull_test()
{
Location[] loc = new Location[7];
Cluster clust = new Cluster();
List<Location> expected = new List<Location>();
loc[0] = new Location(3, 2);
loc[1] = new Location(3, 3);
loc[2] = new Location(3, 4);
loc[3] = new Location(2, 3);
loc[4] = new Location(2, 1);
loc[5] = new Location(1, 2);
loc[6] = new Location(1, 4);
clust.add_location(loc[0]);
clust.add_location(loc[1]);
clust.add_location(loc[2]);
clust.add_location(loc[3]);
clust.add_location(loc[4]);
clust.add_location(loc[5]);
clust.add_location(loc[6]);
expected.Add(loc[4]);
expected.Add(loc[5]);
expected.Add(loc[6]);
expected.Add(loc[2]);
expected.Add(loc[1]);
expected.Add(loc[0]);
List<Location> ch = clust.convex_hull();
for(int i = 0; i < 4; i++)
{
Specify.That(ch[i].Equals(expected[i])).ShouldBeTrue();
}
}
示例4: second_convex_hull_test
public void second_convex_hull_test()
{
Cluster clust = new Cluster();
List<Location> expected = new List<Location>();
Location[] loc = new Location[]
{
new Location(2, 0),
new Location(0, 2),
new Location(2, 4),
new Location(2, 1),
new Location(2, 2),
new Location(4, 2)
};
clust.add_location(loc[0]);
clust.add_location(loc[1]);
clust.add_location(loc[2]);
clust.add_location(loc[3]);
clust.add_location(loc[4]);
clust.add_location(loc[5]);
expected.Add(loc[0]);
expected.Add(loc[1]);
expected.Add(loc[3]);
expected.Add(loc[5]);
List<Location> ch = clust.convex_hull();
for (int i = 0; i < 4; i++)
{
Specify.That(ch[i]).ShouldEqual(expected[i]);
}
}