本文整理汇总了C#中Interval类的典型用法代码示例。如果您正苦于以下问题:C# Interval类的具体用法?C# Interval怎么用?C# Interval使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Interval类属于命名空间,在下文中一共展示了Interval类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Intervals_Are_Constructable_From_Semitones
public void Intervals_Are_Constructable_From_Semitones()
{
var i = new Interval(5);
Assert.Equal(5, i.Semitones);
Assert.Equal(IntervalDistance.PerfectFourth, i.Distance);
}
示例2: AxisAlignedBoxEnvironmentComponentOld
/// <summary>
/// Initializes a new instance of the AbstractEnvironmentComponent class.
/// </summary>
public AxisAlignedBoxEnvironmentComponentOld()
: base(RS.AABoxEnvName, RS.AABoxEnvNickName,
RS.AABoxEnvDescription, RS.icon_AABoxEnvironment, RS.AABoxEnvOldGuid)
{
Interval interval = new Interval(-RS.boxBoundsDefault, RS.boxBoundsDefault);
box = new Box(Plane.WorldXY, interval, interval, interval);
}
示例3: Create
/// <summary>
/// Método estático encargado de la creación de objetos valor <see cref="IInterval"/>
/// </summary>
/// <remarks>
/// Sin comentarios adicionales.
/// </remarks>
/// <param name="fromTime">
/// Parámetro que indica la hora inicial del intervalo.
/// </param>
/// <param name="duration">
/// Parámetro que indica la duración del intervalo.
/// </param>
/// <returns>
/// Devuelve objeto de tipo <see cref="IInterval"/> creado.
/// </returns>
public static IInterval Create(DateTime? fromTime, TimeSpan duration)
{
// Creamos el objeto valor de periodo de vigencia.
IInterval interval = new Interval(fromTime, duration);
// Devolvemos el objeto valor creado.
return interval;
}
示例4: Insert
public IList<Interval> Insert(IList<Interval> intervals, Interval newInterval) {
IList<Interval> result = new List<Interval>();
if(intervals.Count == 0){
result.Add(newInterval);
return result;
}
bool first = true;
for(int i=0; i<intervals.Count; i++){
if(intervals[i].end<newInterval.start){
result.Add(intervals[i]);
}
else if(intervals[i].start>newInterval.end){
if(first){
result.Add(newInterval);
first = false;
}
result.Add(intervals[i]);
}
else{
newInterval = new Interval(Math.Min(newInterval.start, intervals[i].start), Math.Max(newInterval.end, intervals[i].end));
}
}
if(first){
result.Add(newInterval);
first = false;
}
return result;
}
示例5: CompareDecimals
protected ComparerResult CompareDecimals(Interval interval, decimal actual)
{
if (interval.Contains(actual))
return ComparerResult.Equality;
return new ComparerResult(interval.ToString());
}
示例6: Construct1
public void Construct1()
{
var interval = new Interval();
Assert.AreEqual(IntervalMode.Interpolate, interval.Mode);
Assert.AreEqual(0, interval.Time);
Assert.IsNull(interval.Value);
}
示例7: GetIntersectionTest
public void GetIntersectionTest()
{
var A = new Interval(0.0f, 5.0f);
var B = new Interval(2.5f, 7.5f);
var C = new Interval(6.0f, 10.0f);
Interval Temp;
Assert.IsTrue(A.GetIntersection(B, out Temp));
Assert.AreEqual(new float[] { 2.5f, 5.0f }, Temp.ToArray());
Assert.IsTrue(B.GetIntersection(A, out Temp));
Assert.AreEqual(new float[] { 2.5f, 5.0f }, Temp.ToArray());
Assert.IsTrue(A.GetIntersection(A, out Temp));
Assert.AreEqual(A.ToArray(), Temp.ToArray());
Assert.IsTrue(B.GetIntersection(C, out Temp));
Assert.AreEqual(new float[] { 6.0f, 7.5f }, Temp.ToArray());
Assert.IsTrue(C.GetIntersection(B, out Temp));
Assert.AreEqual(new float[] { 6.0f, 7.5f }, Temp.ToArray());
Assert.IsTrue(B.GetIntersection(B, out Temp));
Assert.AreEqual(B.ToArray(), Temp.ToArray());
A.GetIntersection(C, out Temp);
C.GetIntersection(A, out Temp);
Assert.IsFalse(A.GetIntersection(C, out Temp));
Assert.IsFalse(C.GetIntersection(A, out Temp));
}
示例8: ConstructorDefault
public void ConstructorDefault()
{
IInterval<int> interval = new Interval<int>(5, 10);
Assert.AreEqual(5, interval.LowerBound);
Assert.AreEqual(10, interval.UpperBound);
}
示例9: ConstructorWrongOrder
public void ConstructorWrongOrder()
{
IInterval<int> interval = new Interval<int>(10, 5);
Assert.AreEqual(5, interval.LowerBound);
Assert.AreEqual(10, interval.UpperBound);
}
示例10: CheckRoomTouch
//If touching, returns unit vector pointing from A towards B
//else returns 0,0,0
public static Vector3 CheckRoomTouch(Bounds a, Bounds b, float minOverlap)
{
Interval a_x = new Interval(a.min.x, a.max.x);
Interval a_y = new Interval(a.min.y, a.max.y);
Interval a_z = new Interval(a.min.z, a.max.z);
Interval b_x = new Interval(b.min.x, b.max.x);
Interval b_y = new Interval(b.min.y, b.max.y);
Interval b_z = new Interval(b.min.z, b.max.z);
int roomTouchX = Interval.CheckTouching(a_x, b_x);
int roomTouchY = Interval.CheckTouching(a_y, b_y);
int roomTouchZ = Interval.CheckTouching(a_z, b_z);
bool roomOverlapX = Interval.CheckOverlap(a_x, b_x, minOverlap);
bool roomOverlapY = Interval.CheckOverlap(a_y, b_y, minOverlap);
bool roomOverlapZ = Interval.CheckOverlap(a_z, b_z, minOverlap);
//-.-- -.-- --..
if(roomOverlapX && roomOverlapY) return Vector3.forward * roomTouchZ;
if(roomOverlapZ && roomOverlapY) return Vector3.right * roomTouchX;
if(roomOverlapX && roomOverlapZ) return Vector3.up * roomTouchY;
return Vector3.zero;
}
示例11: Construction_EqualStartAndEnd
public void Construction_EqualStartAndEnd()
{
var interval = new Interval(SampleStart, SampleStart);
Assert.AreEqual(SampleStart, interval.Start);
Assert.AreEqual(SampleStart, interval.End);
Assert.AreEqual(new Duration(0), interval.Duration);
}
示例12: SurfaceEmitterType
// Constructor with initial values.
public SurfaceEmitterType(Surface srf)
{
Interval interval = new Interval(0,1);
srf.SetDomain(0, interval);
srf.SetDomain(1, interval);
this.srf = srf;
}
示例13: Test_AddInterval
public void Test_AddInterval()
{
Interval[] empty = new Interval[] { };
Interval[] result;
SortingAlgorithms algo = new SortingAlgorithms();
result = algo.AddInterval(empty,
new Interval { start = 0, end = 2 }
);
Assert.AreEqual(1, result.Length);
result = algo.AddInterval(result,
new Interval { start = 3, end = 5 }
);
Assert.AreEqual(2, result.Length);
result = algo.AddInterval(result,
new Interval { start = 4, end = 6 }
);
Assert.AreEqual(2, result.Length);
result = algo.AddInterval(result,
new Interval { start = 1, end = 4 }
);
Assert.AreEqual(1, result.Length);
}
示例14: CrossingVehicleTimes
/// <summary>
/// Constructor.
/// </summary>
/// <param name="originalArrivingTime">Time when the vehicle originally planned to arrive at the intersection.</param>
/// <param name="remainingDistance">Remaining distance of the vehicle to the intersection.</param>
/// <param name="blockingTime">Time interval when the vehicle is going to block the intersection.</param>
/// <param name="willWaitInFrontOfIntersection">Flag whether vehicle will wait befor intersection or proceed crossing it.</param>
public CrossingVehicleTimes(double originalArrivingTime, double remainingDistance, Interval<double> blockingTime, bool willWaitInFrontOfIntersection)
{
this.originalArrivingTime = originalArrivingTime;
this.remainingDistance = remainingDistance;
this.blockingTime = blockingTime;
this.willWaitInFrontOfIntersection = willWaitInFrontOfIntersection;
}
示例15: Box
/// <summary>
/// Initializes a new Box that mimics a BoundingBox struct.
/// <para>The orientation plane of the Box is coincident with the
/// World XY plane.</para>
/// </summary>
/// <param name="bbox">BoundingBox to mimic.</param>
public Box(BoundingBox bbox)
{
m_plane = Plane.WorldXY;
m_dx = new Interval(bbox.m_min.m_x, bbox.m_max.m_x);
m_dy = new Interval(bbox.m_min.m_y, bbox.m_max.m_y);
m_dz = new Interval(bbox.m_min.m_z, bbox.m_max.m_z);
}