/// <summary> /// get all passed nodes on the way. /// </summary> /// <param name="startTime">The current time.</param> /// <param name="currentSpeed">The current speed.</param> /// <param name="physics">The physics.</param> /// <param name="startNode">The start node.</param> /// <param name="destinationNode">The destination node.</param> /// <param name="checkpointNodes">The checkpoint nodes.</param> /// <param name="checkpointTimes">The checkpoint times.</param> /// <returns> /// check point nodes + times /// </returns> public bool GetCheckPointNodes(double startTime, double currentSpeed, Physic.Physics physics, int startNode, int destinationNode, out List <int> checkpointNodes, out List <double> checkpointTimes) { //get checkpoints checkpointNodes = _graph.getIntermediateNodes(startNode, destinationNode); checkpointTimes = null; if (checkpointNodes == null) { return(false); //no valid way point } checkpointNodes.Insert(0, startNode); checkpointNodes.Add(destinationNode); var checkpointDistances = new List <double>(); foreach (var node in checkpointNodes) { checkpointDistances.Add(_graph.getDistance(startNode, node)); } physics.getTimeNeededToMove(currentSpeed, startTime, checkpointDistances[checkpointDistances.Count - 1], checkpointDistances, out checkpointTimes); return(true); }
/// <summary> /// Creates the intervals for the given parameters. /// /// Node 1 2 3 4 ____________ startIntervalAt /// | /// | /// | ____________ startDrivingAT /// \ /// \ /// \ /// \ /// \ _____________ /// | /// | addIntervallToInfinity == true /// /// </summary> /// <param name="startIntervalAt">The point in time where the intervals should start.</param> /// <param name="startDrivingAt">The point in time the agent starts driving.</param> /// <param name="currentSpeed">The current speed.</param> /// <param name="physics">The physics.</param> /// <param name="startNode">The start node.</param> /// <param name="destinationNode">The destination node.</param> /// <param name="addIntervalToInfinity">if set to <c>true</c> to create intervals until double.PositiveInfinity.</param> /// <returns> /// false, if there is an intersection /// </returns> public List <Interval> CreateIntervals(double startIntervalAt, double startDrivingAt, double currentSpeed, Physic.Physics physics, int startNode, int destinationNode, bool addIntervalToInfinity) { if (currentSpeed > 0 && startIntervalAt == startDrivingAt) { throw new ArgumentException("The agent is already driving => startIntervalAt must be equal to startDrivingAt!"); } List <int> checkPointNodes; List <double> checkPointTimes; var valid = this.GetCheckPointNodes(startDrivingAt, currentSpeed, physics, startNode, destinationNode, out checkPointNodes, out checkPointTimes); if (!valid) { return(null); } return(this.CreateIntervals(startIntervalAt, checkPointNodes, checkPointTimes, addIntervalToInfinity)); }