Beispiel #1
0
        protected void setlane(Lane lane, bool changeilanecontainer)
        {
            // This methods sets a lane. This isn't accomplished by property because of intended side-effects:
            // Crossinglane and roadlane also get changed. We save these two to not always have to cast in case
            // we want to know if Vehicle is on a crossinglane or roadlane.

            if (this.lane == lane)
                return;

            // Remove the Vehicle from the Vehiclelist of Lane. If ChangeIlaneContainer, then also remove Vehicle from the
            // IlaneContainer of the Lane.
            if (this.lane != null)
                this.lane.LeaveLane(this, changeilanecontainer);

            crossinglane = lane as CrossingLane;
            this.lane = lane;
            roadlane = lane as RoadLane;

            trafficlight = roadlane == null ? null : roadlane.TrafficLight;

            if (this.lane != null)
                this.lane.EnterLane(this);
        }
Beispiel #2
0
        private void addlane(LaneDirection lanedirection, LaneType lanetype)
        {
            List<RoadLane> sublanelist = lanelist.Where(l => l.LaneDirection == lanedirection).ToList();
            sublanelist.Sort((l1, l2) => l1.LaneIndex.CompareTo(l2.LaneIndex));

            double translation = sublanelist.Sum(l => l.Width);
            translation += roaddata.LaneWidth/2;

            var lane = new RoadLane(this, lanedirection, lanetype, lanelist.Count(l => l.LaneDirection == lanedirection),
                                    roaddata.LaneWidth, translation);

            if (sublanelist.Count > 0 && lane.LaneType != LaneType.Shoulder)
            {
                lane.LeftLane = sublanelist[sublanelist.Count - 1];
                sublanelist[sublanelist.Count - 1].RightLane = lane;
            }

            lanelist.Add(lane);
        }
Beispiel #3
0
        public void EnterLane(RoadLane lane, RoadLane destinationlane, int bezierindex = 0, double time = 0)
        {
            // Location
            this.bezierindex = bezierindex;
            this.time = time;
            setlane(lane, true);
            location = this.lane.Beziers[bezierindex].GetCoordinate(time);
            velocity = this.lane.Beziers[bezierindex].GetVelocity(time);

            // Destination
            this.destinationlane = destinationlane;
            targetlaneindex = roadlane.GetLaneIndexTo(destinationlane.GetLastCoordinate());

            // Speed
            speedfactor = Math.Abs(Randomizer.NextNormal(ParameterPanel.μSpeed, ParameterPanel.σSpeed));
            targetspeed = Math.Min(speedfactor*roadlane.Road.GetMaximumSpeed(type), modeldata.TopSpeed);
            speed = targetspeed;
            bezierfactor = speed/this.lane.Beziers[bezierindex].Length;
        }
Beispiel #4
0
        public int GetLaneIndexTo(RoadLane currentlane, PointD point)
        {
            Crossing crossing;
            if (currentlane.LaneDirection == LaneDirection.Forward)
                crossing = Next as Crossing;
            else
                crossing = Previous as Crossing;

            return crossing == null ? getlaneindexto(point) : crossing.GetLaneIndexTo(this, point);
        }