public TrafficLightSystem(Crossing crossing) { this.crossing = crossing; roadindex = 0; roadlist = new List<Road>(); time = 0; trafficlightdictionary = new Dictionary<Road, List<TrafficLight>>(); trafficlightstate = TrafficLightState.Yellow; }
//[OptionalField] private RoadLane nextlane; //[OptionalField] private RoadLane previouslane; public CrossingLane(Crossing crossing, Lane previouslane, Lane nextlane, double width, List<Vehicle> vehiclelist) { int colorindex; if (previouslane.LaneDirection == LaneDirection.Forward) colorindex = previouslane.LaneIndex; else colorindex = -previouslane.LaneIndex - 1; Crossing = crossing; curvecolor = Colors.GetSaturatedColor(colorindex); ILaneContainer = crossing; LaneIndex = nextlane.LaneIndex; Width = width; this.vehiclelist = vehiclelist; nextlanes.Add(nextlane); nextlane.AddPreviousLane(this); previouslanes.Add(previouslane); previouslane.AddNextLane(this); PointD point1 = previouslane.GetLastCoordinate(); PointD point2 = nextlane.GetFirstCoordinate(); VectorD vector1 = previouslane.GetLastVelocity(); VectorD vector2 = nextlane.GetFirstVelocity(); VectorD vector3 = vector1.GetUnitVector()*new VectorD(point1, point2).Length/3; if (vector1.IsCoLinearWith(vector2)) // Als de in en uitgaande RoadLane van de die deze CrossingLane verbindt dezelfde richting hebben // If the incoming and outgoing RoadLane that this crossinglane connects have the same direction // we need a third order curve beziers = new Bezier[] {new CubicBezier(point1, point1 + vector3, point2 - vector3, point2)}; else // else a second order beziers = new Bezier[] { new QuadraticBezier(point1, new LineD(point1, vector1).GetCrossingPoint(new LineD(point2, vector2)), point2) }; Length = beziers.Sum(bezier => bezier.Length); }