本文整理汇总了C#中Range.DistanceSquared方法的典型用法代码示例。如果您正苦于以下问题:C# Range.DistanceSquared方法的具体用法?C# Range.DistanceSquared怎么用?C# Range.DistanceSquared使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Range
的用法示例。
在下文中一共展示了Range.DistanceSquared方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: distance_squared_value
public void distance_squared_value() {
var a = new Range(0, 0);
var b = new Range(-1, 1);
var c = new Range(5, -10);
Assert.Equal(0, a.DistanceSquared(0));
Assert.Equal(4, a.DistanceSquared(2));
Assert.Equal(0, b.DistanceSquared(1));
Assert.Equal(9, b.DistanceSquared(-4));
Assert.Equal(1, b.DistanceSquared(-2));
Assert.Equal(1, b.DistanceSquared(2));
Assert.Equal(0, c.DistanceSquared(1));
Assert.Equal(0, c.DistanceSquared(3));
Assert.Equal(9, c.DistanceSquared(8));
Assert.Equal(100, c.DistanceSquared(-20));
}
示例2: distance_squared_range
public void distance_squared_range() {
var a = new Range(0, 0);
var b = new Range(1, 1);
var c = new Range(1, 2);
var d = new Range(3, 2);
var e = new Range(-2, -1);
Assert.Equal(0, a.DistanceSquared(a));
Assert.Equal(0, b.DistanceSquared(b));
Assert.Equal(1, a.DistanceSquared(b));
Assert.Equal(1, b.DistanceSquared(a));
Assert.Equal(0, c.DistanceSquared(d));
Assert.Equal(0, d.DistanceSquared(c));
Assert.Equal(4, c.DistanceSquared(e));
Assert.Equal(4, e.DistanceSquared(c));
}