public Connection(Bezier bezier, Lane startlane, Lane endlane, int startbezierindex, int endbezierindex, double starttimeindex, double endtimeindex, double unspawnindex = double.NaN) { Bezier = bezier; StartLane = startlane; EndLane = endlane; StartBezierIndex = startbezierindex; EndBezierIndex = endbezierindex; StartTime = starttimeindex; EndTime = endtimeindex; UnSpawnTimeIndex = unspawnindex; }
//[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); }
public Road(RoadData roaddata, Bezier[] beziers) { this.beziers = beziers; linecolor = roaddata.LineColor; lanelist = new List<RoadLane>(); roadcolor = roaddata.RoadColor; this.roaddata = roaddata; vehiclelist = new List<Vehicle>(); for (int i = 0; i < roaddata.ForwardLaneCount; i++) if (i == roaddata.ForwardLaneCount - 1 && roaddata.ForwardShoulder) addlane(LaneDirection.Forward, LaneType.Shoulder); else addlane(LaneDirection.Forward, LaneType.Normal); for (int i = 0; i < roaddata.BackwardLaneCount; i++) if (i == roaddata.BackwardLaneCount - 1 && roaddata.BackwardShoulder) addlane(LaneDirection.Backward, LaneType.Shoulder); else addlane(LaneDirection.Backward, LaneType.Normal); }
private void setbeziers() { Bezier[] roadbeziers = Road.Beziers; bool reverse = LaneDirection == LaneDirection.Backward; beziers = new Bezier[roadbeziers.Length]; linebeziers = new Bezier[roadbeziers.Length]; for (int i = 0; i < beziers.Length; i++) { beziers[i] = roadbeziers[i].GetTranslatedBezier(reverse, translation); linebeziers[i] = roadbeziers[i].GetTranslatedBezier(reverse, translation + Width/2); } if (!reverse) return; beziers = beziers.Reverse().ToArray(); linebeziers = linebeziers.Reverse().ToArray(); }