本文整理汇总了C#中Location.distance_from方法的典型用法代码示例。如果您正苦于以下问题:C# Location.distance_from方法的具体用法?C# Location.distance_from怎么用?C# Location.distance_from使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Location
的用法示例。
在下文中一共展示了Location.distance_from方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: test_the_distance_from_one_loc_to_another
public void test_the_distance_from_one_loc_to_another()
{
Location loc1 = new Location(5, 6);
Location loc2 = new Location(5, 6);
Location loc3 = new Location(5, 5);
Location loc4 = new Location(20, -5);
Specify.That(loc1.distance_from(loc2)).ShouldEqual(0);
float x_dist = 5 - 5;
float y_dist = 6 - 5;
Specify.That(loc1.distance_from(loc3)).ShouldEqual((float)Math.Sqrt(Math.Pow(x_dist, 2) + Math.Pow(y_dist, 2)));
x_dist = 5 - 5;
y_dist = 5 - 6;
Specify.That(loc3.distance_from(loc1)).ShouldEqual((float)Math.Sqrt(Math.Pow(x_dist, 2) + Math.Pow(y_dist, 2)));
x_dist = 5 - 20;
y_dist = 6 - -5;
Specify.That(loc1.distance_from(loc4)).ShouldEqual((float)Math.Sqrt(Math.Pow(x_dist, 2) + Math.Pow(y_dist, 2)));
}