本文整理汇总了C#中IGraph.GetSegment方法的典型用法代码示例。如果您正苦于以下问题:C# IGraph.GetSegment方法的具体用法?C# IGraph.GetSegment怎么用?C# IGraph.GetSegment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IGraph
的用法示例。
在下文中一共展示了IGraph.GetSegment方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DisplayGraph
/// <summary>
/// Displays the provided function
/// </summary>
/// <param name="graph"></param>
/// <param name="maxDistance"></param>
/// <param name="startingPoint"></param>
private void DisplayGraph(IGraph graph, double maxDistance, SpeedDistancePoint startingPoint)
{
if (graph != null && startingPoint != null)
{
// This empty data point is added in order to allow displaying several
// deceleration curves without linking the end of the previous curve
// with the start of the following curve
DataPoint dataPoint = new DataPoint(0, 0);
for (int i = 0; i < graph.CountSegments(); i++)
{
ISegment segment = graph.GetSegment(i);
if (segment.D0 <= maxDistance && (segment.D0 >= startingPoint.Distance || (segment.Length == double.MaxValue || segment.D0 + segment.Length > startingPoint.Distance)))
{
double startLocation = Math.Max(startingPoint.Distance, segment.D0);
double endLocation = maxDistance;
if (!double.IsNaN(segment.Length))
{
endLocation = Math.Min(segment.D0 + segment.Length, endLocation);
}
if (segment.A == 0) // this is a flat segment
{
AddPoint(new DataPoint(startLocation, segment.V0));
AddPoint(new DataPoint(endLocation, segment.V0));
}
else // this is a curve
{
double distanceInterval = (endLocation - startLocation) /
GraphVisualizer.DecelerationCurvePrecision;
double distance = startLocation;
for (int j = 0; j < GraphVisualizer.DecelerationCurvePrecision; j++)
{
AddDataPoint(distance, segment);
distance += distanceInterval;
}
AddDataPoint(distance, segment);
}
}
}
dataPoint = new DataPoint(0, 0);
dataPoint.IsEmpty = true;
AddPoint(dataPoint);
}
}
示例2: UpdateFunction
/// <summary>
/// Updates the provided function and relocates it according to the value of increment
/// </summary>
/// <param name="graph"></param>
/// <param name="lrbgPosition"></param>
protected void UpdateFunction(IGraph graph, double lrbgPosition)
{
if (graph != null)
{
for (int i = 0; i < graph.CountSegments(); i++)
{
graph.GetSegment(i).D0 += lrbgPosition;
}
}
}