Microscopic Traffic Simulator

- Main Page
- Packages
- Classes
- Files

- File List

StraightLane.cs
Go to the documentation of this file.
1 using System;
2 using System.Collections.Generic;
3 using System.Windows;
4
5 namespace Microscopic_Traffic_Simulator___Model.GeometricObjects.Lanes
6 {
10 [Serializable]
11 public class StraightLane : Lane
12 {
18 public StraightLane(Point startPoint, Point endPoint) : base(startPoint, endPoint) { }
19
25 internal override IEnumerable<Point> LanePoints(double lanePointsMaxDistance)
26 {
27 //Get vector from start point to end point.
28 Vector startToEndVector = endNode.Location - startNode.Location;
29 //Get vector from one lane point to other lane point
30 Vector cellStartToEndVector = startToEndVector;
31 cellStartToEndVector.Normalize();
32 cellStartToEndVector *= lanePointsMaxDistance;
33 //Get count of points which will be returned.
34 int lanePointsCount = (int)(startToEndVector.Length / cellStartToEndVector.Length) + 1;
35 //Go through the lane and return points.
36 Point currentPoint = startNode.Location;
37 for (int i = 0; i < lanePointsCount; i++)
38 {
39 yield return currentPoint;
40 currentPoint += cellStartToEndVector;
41 }
42 //Return end point location as the additional lane point if it was not returned in the loop above.
43 if (currentPoint != endNode.Location)
44 {
45 yield return endNode.Location;
46 }
47 }
48 }
49 }
Microscopic_Traffic_Simulator___Model.GeometricObjects.Lanes.StraightLane
Represents single straight lane.
Definition: StraightLane.cs:11
System
Microscopic_Traffic_Simulator___Model.GeometricObjects.Lanes.StraightLane.StraightLane
StraightLane(Point startPoint, Point endPoint)
Constructor of straight lane.
Definition: StraightLane.cs:18
Microscopic_Traffic_Simulator___Model.GeometricObjects.Lanes.Lane
Represent single lane.
Definition: Lane.cs:14
Microscopic_Traffic_Simulator___Model