Ejemplo n.º 1
0
    void crossingWithoutPedestrian()
    {
        Oriention[] todo = { Oriention.Degree0, Oriention.Degree90, Oriention.Degree180, Oriention.Degree270 };
        foreach (Oriention localO in todo)
        {
            Oriention o = getGlobalOrientationFromLocal(localO, this.Oriention);

            roadPiece rp3deg0EndPoint = new roadPiece(endPoints[(int)Oriention.Degree0]);
            rp3deg0EndPoint.orientation = getGlobalOrientationFromLocal(global::Oriention.Degree0, o);
            rp3deg0EndPoint.coordinate  = new System.Drawing.Point(10, 10);

            roadPiece rp1 = new roadPiece(rp3deg0EndPoint);
            rp1.orientation = getGlobalOrientationFromLocal(global::Oriention.Degree90, o);
            rp1.coordinate  = new System.Drawing.Point(10, 10);


            roadPiece rp5deg90EndPoint = new roadPiece(endPoints[(int)Oriention.Degree90]);
            rp5deg90EndPoint.orientation = getGlobalOrientationFromLocal(global::Oriention.Degree90, o);
            rp5deg90EndPoint.coordinate  = new System.Drawing.Point(10, 10);

            roadPiece rp6deg180EndPoint = new roadPiece(endPoints[(int)Oriention.Degree180]);
            rp6deg180EndPoint.orientation = getGlobalOrientationFromLocal(global::Oriention.Degree180, o);
            rp6deg180EndPoint.coordinate  = new System.Drawing.Point(10, 10);

            roadPiece rp4 = new roadPiece(new roadPiece[] { rp6deg180EndPoint, rp5deg90EndPoint });
            rp4.orientation = getGlobalOrientationFromLocal(global::Oriention.Degree90, o);
            rp4.coordinate  = new System.Drawing.Point(10, 10);

            roadPiece rp2 = new roadPiece(rp4);
            rp2.orientation = getGlobalOrientationFromLocal(global::Oriention.Degree90, o);
            rp2.coordinate  = new System.Drawing.Point(10, 10);

            roadPiece rp0StartPoint = new roadPiece(new roadPiece[] { rp2, rp1 });
            rp0StartPoint.orientation = getGlobalOrientationFromLocal(global::Oriention.Degree90, o);
            rp0StartPoint.coordinate  = new System.Drawing.Point(10, 10);

            //  assign the start point
            this.ReferencePath[(int)localO] = rp0StartPoint;
        }
    }
Ejemplo n.º 2
0
 public void SetOrientation(Oriention arg)
 {
     throw new System.NotImplementedException();
 }
Ejemplo n.º 3
0
    public Oriention getGlobalOrientationFromLocal(Oriention local, Oriention global)
    {
        int localAngle = 0;

        switch (local)
        {
        case Oriention.Degree0:
            localAngle = 0;
            break;

        case Oriention.Degree180:
            localAngle = 180;
            break;

        case Oriention.Degree270:
            localAngle = 270;
            break;

        case Oriention.Degree90:
            localAngle = 90;
            break;
        }

        int globalAngle = 0;

        switch (global)
        {
        case Oriention.Degree0:
            globalAngle = 0;
            break;

        case Oriention.Degree180:
            globalAngle = 180;
            break;

        case Oriention.Degree270:
            globalAngle = 270;
            break;

        case Oriention.Degree90:
            globalAngle = 90;
            break;
        }
        int resultAngle = (globalAngle + localAngle) % 360;

        switch (resultAngle)
        {
        case 0:
            return(Oriention.Degree0);

        case 180:
            return(Oriention.Degree180);

        case 270:
            return(Oriention.Degree270);

        case 90:
            return(Oriention.Degree90);
        }
        // We want to come back to [0, 270]

        return(local);
    }
Ejemplo n.º 4
0
    void crossingWithPedestrian()
    {
        pedestrianStartPoint = new roadPiece[2];
        Oriention[] todo = { Oriention.Degree0, Oriention.Degree180 };
        foreach (Oriention localO in todo)
        {
            // Pedestrian road
            pedestrianStartPoint[(int)localO] = new roadPiece((roadPiece)null);
            // car road

            Oriention o = getGlobalOrientationFromLocal(localO, this.Oriention);

            roadPiece rp2RightEndPoint = new roadPiece(endPoints[(int)Oriention.Degree0]);
            rp2RightEndPoint.orientation = getGlobalOrientationFromLocal(global::Oriention.Degree0, o);
            rp2RightEndPoint.coordinate  = new System.Drawing.Point(10, 10);

            roadPiece rp4TopEndPoint = new roadPiece(endPoints[(int)Oriention.Degree90]);
            rp4TopEndPoint.orientation = getGlobalOrientationFromLocal(global::Oriention.Degree90, o);
            rp4TopEndPoint.coordinate  = new System.Drawing.Point(10, 10);

            roadPiece rp5LeftEndPoint = new roadPiece(endPoints[(int)Oriention.Degree180]);
            rp5LeftEndPoint.orientation = getGlobalOrientationFromLocal(global::Oriention.Degree180, o);
            rp5LeftEndPoint.coordinate  = new System.Drawing.Point(10, 10);

            roadPiece rp3 = new roadPiece(new roadPiece[] { rp4TopEndPoint, rp5LeftEndPoint });
            rp3.orientation = getGlobalOrientationFromLocal(global::Oriention.Degree90, o);
            rp3.coordinate  = new System.Drawing.Point(10, 10);

            roadPiece rp1 = new roadPiece(new roadPiece[] { rp3, rp2RightEndPoint });
            rp1.orientation = getGlobalOrientationFromLocal(global::Oriention.Degree90, o);
            rp1.coordinate  = new System.Drawing.Point(10, 10);

            roadPiece rp0StartPoint = new roadPiece(rp1);
            rp0StartPoint.orientation = getGlobalOrientationFromLocal(global::Oriention.Degree90, o);
            rp0StartPoint.coordinate  = new System.Drawing.Point(10, 10);
            //  assign the start point
            this.ReferencePath[(int)localO] = rp0StartPoint;
        }

        // A5,A6, ...
        Oriention[] todo2 = { Oriention.Degree90, Oriention.Degree270 };
        foreach (Oriention localO in todo2)
        {
            Oriention o = getGlobalOrientationFromLocal(localO, this.Oriention);

            roadPiece rp12BottomEndPoint = new roadPiece(endPoints[(int)Oriention.Degree270]);
            rp12BottomEndPoint.orientation = getGlobalOrientationFromLocal(global::Oriention.Degree270, o);
            rp12BottomEndPoint.coordinate  = new System.Drawing.Point(10, 10);

            roadPiece rp11 = new roadPiece(rp12BottomEndPoint);
            rp11.orientation = getGlobalOrientationFromLocal(global::Oriention.Degree180, o);
            rp11.coordinate  = new System.Drawing.Point(10, 10);

            roadPiece rp16RightEndPoint = new roadPiece(endPoints[(int)Oriention.Degree0]);
            rp16RightEndPoint.orientation = getGlobalOrientationFromLocal(global::Oriention.Degree0, o);
            rp16RightEndPoint.coordinate  = new System.Drawing.Point(10, 10);

            roadPiece rp17TopEndPoint = new roadPiece(endPoints[(int)Oriention.Degree90]);
            rp17TopEndPoint.orientation = getGlobalOrientationFromLocal(global::Oriention.Degree90, o);
            rp17TopEndPoint.coordinate  = new System.Drawing.Point(10, 10);

            roadPiece rp15 = new roadPiece(rp16RightEndPoint);
            rp15.orientation = getGlobalOrientationFromLocal(global::Oriention.Degree0, o);
            rp15.coordinate  = new System.Drawing.Point(10, 10);

            roadPiece rp14 = new roadPiece(new roadPiece[] { rp17TopEndPoint, rp15 });
            rp14.orientation = getGlobalOrientationFromLocal(global::Oriention.Degree0, o);
            rp14.coordinate  = new System.Drawing.Point(10, 10);

            roadPiece rp13 = new roadPiece(rp14);
            rp13.orientation = getGlobalOrientationFromLocal(global::Oriention.Degree0, o);
            rp13.coordinate  = new System.Drawing.Point(10, 10);

            roadPiece rp10StartPoint = new roadPiece(rp13);
            rp10StartPoint.orientation = getGlobalOrientationFromLocal(global::Oriention.Degree0, o);
            rp10StartPoint.coordinate  = new System.Drawing.Point(10, 10);

            this.ReferencePath[(int)localO] = rp10StartPoint;
        }
    }