예제 #1
0
        //Methods
        public carinjector(road aroadon, int apointn, double aninjectperiod, double adt)
        {
            roadon           = aroadon;
            carlane          = roadon.nlanes - 1;
            location         = roadon.points[apointn];
            pointn           = apointn;
            carstartlocation = new point(0, 0);

            double bias;     // 'for direction

            if (apointn == 0)
            {
                bias = 0;
            }
            else
            {
                bias = Math.PI;
            }

            direction    = roadon.direction + bias;
            highlighted  = false;
            dt           = adt;
            timer        = 0.0;
            injectperiod = aninjectperiod;
            injectnow    = false;
            calccarstartlocation();
        }
예제 #2
0
        public void calcmobilepointstartofroad(car thecar, road newroad, int lanenr)
        {
            double bias;     // 'for direction
            int    side;

            if (thecar.roadon.points[thecar.destination01] == newroad.points[0])
            {
                bias = 0;
            }
            else
            {
                bias = Math.PI;
            }

            side          = global.CarSide == carsidet.Right ? 1 : -1;
            mobilepoint.x = thecar.roadon.points[thecar.destination01].x +
                            thecar.roadon.points[thecar.destination01].crossingradius *
                            Math.Cos(newroad.direction + bias) +
                            newroad.nlanes * newroad.roadlanewidth *
                            Math.Cos(newroad.direction + bias + side * Math.PI / 2);
            mobilepoint.y = thecar.roadon.points[thecar.destination01].y +
                            thecar.roadon.points[thecar.destination01].crossingradius *
                            Math.Sin(newroad.direction + bias) +
                            newroad.nlanes * newroad.roadlanewidth *
                            Math.Sin(newroad.direction + bias + side * Math.PI / 2);
        }
예제 #3
0
        //Methods
        public trafficlight(double aredlength, double ayellowlength, double agreenlength,
                            double atime, road aroadon,
                            double ax, double ay, int apointpointedto, double adt)
        {
            redlength    = aredlength;
            yellowlength = ayellowlength;
            greenlength  = agreenlength;
            colour       = trafficlightcolour.Green; //just to have any start-up colour
            timer        = atime;
            roadon       = aroadon;

            pointpointedto = apointpointedto;
            if (pointpointedto == 0)
            {
                pointnotpointedto = 1;
            }
            else
            {
                pointnotpointedto = 0;
            }
            location           = new point(0, 0);
            graphlocation      = new point(0, 0);
            graphblacklocation = new point(0, 0);

            calcdirectionlocation(ax, ay);

            dt          = adt;
            highlighted = false;
            //resettimer();
        }
예제 #4
0
        public void calcmobilepointendofroad(road theroad, int destination01, int lanenr)
        //This method might become redundant if the new equivalent method in the car class can be used.
        {
            double bias;     // 'for direction
            int    side;

            if (destination01 == 1)
            {
                bias = 0;
            }
            else
            {
                bias = Math.PI;
            }

            side          = global.CarSide == carsidet.Right ? 1 : -1;
            mobilepoint.x = theroad.points[destination01].x +
                            theroad.points[destination01].crossingradius *
                            Math.Cos(theroad.direction + bias + Math.PI) +
                            (lanenr + 1) * theroad.roadlanewidth *
                            Math.Cos(theroad.direction + bias + side * Math.PI / 2);
            mobilepoint.y = theroad.points[destination01].y +
                            theroad.points[destination01].crossingradius *
                            Math.Sin(theroad.direction + bias + Math.PI) +
                            (lanenr + 1) * theroad.roadlanewidth *
                            Math.Sin(theroad.direction + bias + side * Math.PI / 2);
        }
예제 #5
0
 public mycar(double aspeed, double adt, point alocation,
              point adestination, road aroadon, int adestination01,
              double abreakacceleration)
     : base(aspeed, adt, alocation,
            adestination, aroadon, adestination01,
            abreakacceleration)
 {
     carcolour = global.MyCarColour;
     cartype   = cartypes.MyCar;
 }
예제 #6
0
 public void newdestination(point adestination, road aroadon, int adestination01)
 {
     destination.copyfrom(adestination);
     //destination = adestination;  //This does not work for some reason.
     atdestination = false;
     roadon        = aroadon;
     destination01 = adestination01;
     updatedirection();
     //destinationlane = adestinationlane;
 }
예제 #7
0
        public roadproperties(int aroadnr, simulation asim)
        {
            InitializeComponent();

            sim     = asim;
            roadnr  = aroadnr;
            theroad = sim.roads[roadnr];
            Text    = String.Concat("Properties for road number: ", roadnr.ToString());
            numericUpDown1.Value = Convert.ToDecimal(theroad.nlanes);
            label3.Text          = Math.Round(theroad.direction * 180 / Math.PI, 2).ToString();
            label5.Text          = Math.Round(theroad.distance, 2).ToString();
        }
예제 #8
0
        public double direction; // 'radians
        //int pointpointedto, pointnotpointedto; //Let's define the point at the end of the road on teh side
        //							//the building is on, as the point pointed to.

        //Methods
        public building(road aroadon, point alocation,
                        double adirection)
        {
            roadon = aroadon;

            /* pointpointedto = apointpointedto;
             * pointpointedto == 0 ? pointnotpointedto = 1 : pointnotpointedto = 0;*/

            direction = adirection;

            location           = alocation;
            closestpointinroad = new point(0, 0);
            middleofbuilding   = new point(0, 0);
            calcclosestpointinroad();
        }
예제 #9
0
        //Methods
        public car(double aspeed, double adt, point alocation,
                   point adestination, road aroadon, int adestination01,
                   double abreakacceleration)
        {
            speed          = aspeed;
            preferredspeed = speed;
            dt             = adt;
            calcdeltalocation();

            location = alocation;

            destination = new point(0, 0);
            newdestination(adestination, aroadon, adestination01);
            atdestination = false;

            breakacceleration = abreakacceleration;
            calcbreakdistance();
            mode               = carmode.Normal;
            ontrajectory       = false;
            side               = global.DefaultCarSide;
            distancecontroller = new pidcontroller(global.KDistanceController, global.IDistanceController, 0,
                                                   global.MinCarSpeed, global.MaxCarSpeed);
            speedcontroller = new pidcontroller(global.KSpeedController, global.ISpeedController, 0,
                                                global.MinCarSpeed, global.MaxCarSpeed);
            speedcontroller.direction = global.Reverse;
            speedcontroller.init(preferredspeed, speed, speed);
            maxspeed           = global.MaxCarSpeed;
            wlangle            = Math.Atan(global.CarWidth / global.CarLength);
            cardiag            = Math.Sqrt(Math.Pow(global.CarWidth, 2) + Math.Pow(global.CarLength, 2)) / 2 * global.GScale;
            cardiagkm          = Math.Sqrt(Math.Pow(global.CarWidth, 2) + Math.Pow(global.CarLength, 2)) / 2;
            highlighted        = false;
            decisiont          = decisiontype.RandomDecision;
            buildingfrom       = 0;
            buildingto         = 1;
            route              = new List <int>(0);
            currentstepinroute = 0;
            lane           = 0;
            changinglanes  = false;
            cartobedeleted = false;
            newroadn       = 0;

            timetotargetspeed = 50 * global.PSpeedController / global.SampleT;
            carcolour         = global.CarColour;
            cartype           = cartypes.OtherCar;
        }
예제 #10
0
        //Methods
        public stopsign(road aroadon, double ax, double ay, int apointpointedto, double adt)
        {
            roadon = aroadon;

            pointpointedto = apointpointedto;
            if (pointpointedto == 0)
            {
                pointnotpointedto = 1;
            }
            else
            {
                pointnotpointedto = 0;
            }
            location           = new point(0, 0);
            graphlocation      = new point(0, 0);
            graphblacklocation = new point(0, 0);

            calcdirectionlocation(ax, ay);

            dt = adt;
        }
예제 #11
0
        public double dt;     //TSim for the simulation

        //Methods
        public carextractor(road aroadon, int apointn, double adt)
        {
            roadon   = aroadon;
            location = roadon.points[apointn];
            pointn   = apointn;

            double bias;     // 'for direction

            if (apointn == 1)
            {
                bias = 0;
            }
            else
            {
                bias = Math.PI;
            }

            direction   = roadon.direction + bias;
            highlighted = false;
            dt          = adt;
        }
예제 #12
0
 public void newdestinationlane(point adestination, road aroadon, int adestination01, int adestinationlane)
 {
 }