本文整理汇总了C#中Range.Overlaps方法的典型用法代码示例。如果您正苦于以下问题:C# Range.Overlaps方法的具体用法?C# Range.Overlaps怎么用?C# Range.Overlaps使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Range
的用法示例。
在下文中一共展示了Range.Overlaps方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Overlaps_should_return_correct_value
public void Overlaps_should_return_correct_value(int a1, int a2, int b1, int b2, bool expected)
{
var subject = new Range<int>(a1, a2);
var comparand = new Range<int>(b1, b2);
subject.Overlaps(comparand).Should().Be(expected);
}
示例2: RangeOverlaps01Test
public void RangeOverlaps01Test()
{
Range<int> range = new Range<int>(12, 20);
Range<int> ra = new Range<int>(4, 8);
Range<int> rb = new Range<int>(10, 16);
Range<int> rc = new Range<int>(10, 24);
Range<int> rd = new Range<int>(12, 14);
Range<int> re = new Range<int>(14, 18);
Range<int> rf = new Range<int>(18, 20);
Range<int> rg = new Range<int>(12, 20);
Range<int> rh = new Range<int>(12, 24);
Range<int> ri = new Range<int>(20, 24);
Range<int> rj = new Range<int>(22, 24);
Assert.IsFalse(range.Overlaps(ra));
Assert.IsTrue(range.Overlaps(rb));
Assert.IsTrue(range.Overlaps(rc));
Assert.IsTrue(range.Overlaps(rd));
Assert.IsTrue(range.Overlaps(re));
Assert.IsTrue(range.Overlaps(rf));
Assert.IsTrue(range.Overlaps(rg));
Assert.IsTrue(range.Overlaps(rh));
Assert.IsTrue(range.Overlaps(ri));
Assert.IsFalse(range.Overlaps(rj));
}
示例3: CollidesWith
public bool CollidesWith(LineSegment lineSegment)
{
var sLine = new Line(lineSegment.Point1, lineSegment.Point2.Substract(lineSegment.Point1));
if (!sLine.CollidesWith(this))
{
return false;
}
var rRange = new Range(Origin.X, Origin.X + Size.X);
var sRange = new Range(lineSegment.Point1.X, lineSegment.Point2.X);
sRange = sRange.SortRange();
if (!rRange.Overlaps(sRange))
{
return false;
}
rRange = new Range(Origin.Y, Origin.Y + Size.Y);
sRange = new Range(lineSegment.Point1.Y, lineSegment.Point2.Y);
sRange = sRange.SortRange();
return rRange.Overlaps(sRange);
}
示例4: OverlapsReturnsTrue
public void OverlapsReturnsTrue(Range overlappingRange)
{
Assert.True(overlappingRange.Overlaps(TargetRange));
Assert.True(TargetRange.Overlaps(overlappingRange));
}
示例5: OverlapsReturnsFalse
public void OverlapsReturnsFalse(Range nonOverlappingRange)
{
Assert.False(nonOverlappingRange.Overlaps(TargetRange));
Assert.False(TargetRange.Overlaps(nonOverlappingRange));
}
示例6: Overlaps
public void Overlaps(Range<int> r1, Range<int> r2, bool expected )
{
bool actual = r1.Overlaps(r2);
Assert.AreEqual(expected, actual);
}
示例7: overlaps_range
public void overlaps_range() {
var a = new Range(1, 2);
var b = new Range(3, 3);
var c = new Range(0, 1.5);
var d = new Range(1.5, 3);
Assert.True(a.Overlaps(a));
Assert.False(a.Overlaps(b));
Assert.True(a.Overlaps(c));
Assert.True(a.Overlaps(d));
Assert.False(b.Overlaps(a));
Assert.True(b.Overlaps(b));
Assert.False(b.Overlaps(c));
Assert.False(b.Overlaps(d));
Assert.True(c.Overlaps(a));
Assert.False(c.Overlaps(b));
Assert.True(c.Overlaps(c));
Assert.False(c.Overlaps(d));
Assert.True(d.Overlaps(a));
Assert.False(d.Overlaps(b));
Assert.False(d.Overlaps(c));
Assert.True(d.Overlaps(d));
}
示例8: overlaps_value
public void overlaps_value() {
var a = new Range(1, 2);
var b = new Range(3, 3);
Assert.False(a.Overlaps(0));
Assert.False(a.Overlaps(1));
Assert.True(a.Overlaps(1.5));
Assert.False(a.Overlaps(2));
Assert.False(a.Overlaps(3));
Assert.False(b.Overlaps(2));
Assert.True(b.Overlaps(3));
Assert.False(b.Overlaps(4));
}