private Vector3 CoordinateForRoadWithAbstractRoadInfos(Intersection intersection, Road connectedRoad, RightOrLeft rtlt,
                                                           AbstractWayInfo[] infos)
    {
        infos = AbstractWayInfo.sortAbstractWayInfos(infos);

        // convert the road to an abstract way info
        AbstractWayInfo info = new AbstractWayInfo(IntersectionMath.getOutgoingVector(intersection, connectedRoad).normalized,
                                                   connectedRoad.GetRoadWidth());
        // TODO : CHECK FOR nonexistent index
        int index = 0;

        for (int i = 0; i < infos.Length; i++)
        {
            if (infos[i] == info)
            {
                index = i;
            }
        }

        Vector3[] vertices = MeshVerticesForAbstractWayInfos(infos);

        switch (rtlt)
        {
        case RightOrLeft.LEFT:
            return(vertices[index - 1 < 0 ? infos.Length - 1 : index - 1]);

        case RightOrLeft.RIGHT:
            return(vertices[index]);
        }
        Debug.LogError("Semantics Error, please check");

        return(Vector3.zero);
    }
    private GameObject buildMultiwayIntersectionWithVectors(Intersection intersection, AbstractWayInfo[] outgoingWays)
    {
        // sort vectors according to orientations first
        AbstractWayInfo[] sorted = AbstractWayInfo.sortAbstractWayInfos(outgoingWays);
        Mesh mesh = new Mesh();

        var vertices = MeshVerticesForAbstractWayInfos(sorted);

        mesh.vertices = vertices;

        int[] triangles = new int[outgoingWays.Length * 3];
        // TODO : Figure out how sortBy works, thus affecting the orientation of the plane
        for (int i = 0; i < sorted.Length; i++)
        {
            triangles [i * 3 + 2] = i;
            triangles [i * 3 + 1] = sorted.Length + 1;
            triangles [i * 3 + 0] = i + 1;
        }
        mesh.triangles = triangles;

        Vector2[] uv = new Vector2[vertices.Length];
        for (int i = 0; i < sorted.Length + 1; i++)
        {
            switch (i % 4)
            {
            case 0:
                uv [i] = new Vector2(0, 0);
                break;

            case 1:
                uv [i] = new Vector2(0, 1);
                break;

            case 2:
                uv [i] = new Vector2(1, 1);
                break;

            case 3:
                uv [i] = new Vector2(1, 0);
                break;
            }
        }
        uv [sorted.Length + 1] = new Vector2(0.5f, 0.5f);
        mesh.uv = uv;

        Vector3[] normals = new Vector3[uv.Length];
        for (int i = 0; i < normals.Length; i++)
        {
            normals [i] = Vector3.up;
        }
        mesh.normals = normals;



        var intersectionObj = createGameObjectWithPrefabPositionAndMesh(fourWayIntersectionPrefab, intersection.position, mesh, intersection.customization);


        return(intersectionObj);
    }