コード例 #1
0
ファイル: ChanGen.cs プロジェクト: Urankhai/3DChaSi
    // Start is called before the first frame update
    void Start()
    {
        GameObject LookUpT = GameObject.Find("LookUpTables");
        LookUpTableGen LUT_Script = LookUpT.GetComponent<LookUpTableGen>();
        GlobeCom2 = LUT_Script.GC2; // coordinates, normals, distances, departing and arriving angles
        GlobeCom3 = LUT_Script.GC3; // coordinates, normals, distances, departing and arriving angles

        GameObject MPC_Spawner = GameObject.Find("Direct_Solution");
        Correcting_polygons MPC_Script = MPC_Spawner.GetComponent<Correcting_polygons>();
        MPC1 = MPC_Script.SeenV6_MPC1;
        MPC2 = MPC_Script.SeenV6_MPC2;
        MPC3 = MPC_Script.SeenV6_MPC3;

        // assigning sripts names to the Tx and Rx
        Tx_Seen_MPC_Script = Tx.GetComponent<Transceiver_Channel>();
        Rx_Seen_MPC_Script = Rx.GetComponent<Transceiver_Channel>();
    }
コード例 #2
0
    // Start is called before the first frame update
    void Start()
    {
        /// for Fourier transform

        X_inputValues = new double[Nfft];
        for (int i = 0; i < Nfft; i++)
        {
            X_inputValues[i] = i;
        }

        // ground reflection
        Z = (float)Math.Sqrt(RelativePermitivity - 1);

        // finding the script
        GameObject     LookUpT    = GameObject.Find("LookUpTables");
        LookUpTableGen LUT_Script = LookUpT.GetComponent <LookUpTableGen>();


        // reading info about MPC2
        LinearGlobeCom2          = LUT_Script.Linear_GC2;
        IndexesGlobeCom2         = LUT_Script.Indexes_GC2;
        MaxLengthOfSeenMPC2Lists = LUT_Script.MaxLengthOfSeenMPC2Lists;

        flag_LoS = 0; // flag will be needed for the edge effect

        // test allocation nativearrays
        LookUpTable2   = new NativeArray <GeoComp>(LinearGlobeCom2.Count, Allocator.Persistent);
        LookUpTable2ID = new NativeArray <Vector2Int>(IndexesGlobeCom2.Count, Allocator.Persistent);

        for (int i = 0; i < LinearGlobeCom2.Count; i++)
        {
            LookUpTable2[i] = LinearGlobeCom2[i];
        }
        for (int i = 0; i < IndexesGlobeCom2.Count; i++)
        {
            LookUpTable2ID[i] = IndexesGlobeCom2[i];
        }

        // reading info about MPC3
        LinearGlobeCom3          = LUT_Script.Linear_GC3;
        IndexesGlobeCom3         = LUT_Script.Indexes_GC3;
        MaxLengthOfSeenMPC3Lists = LUT_Script.MaxLengthOfSeenMPC3Lists;

        LookUpTable3   = new NativeArray <GeoComp>(LinearGlobeCom3.Count, Allocator.Persistent);
        LookUpTable3ID = new NativeArray <Vector2Int>(IndexesGlobeCom3.Count, Allocator.Persistent);

        for (int i = 0; i < LinearGlobeCom3.Count; i++)
        {
            LookUpTable3[i] = LinearGlobeCom3[i];
        }
        for (int i = 0; i < IndexesGlobeCom3.Count; i++)
        {
            LookUpTable3ID[i] = IndexesGlobeCom3[i];
        }
        // test allocation nativearrays



        GameObject          MPC_Spawner = GameObject.Find("Direct_Solution");
        Correcting_polygons MPC_Script  = MPC_Spawner.GetComponent <Correcting_polygons>();

        MPC1 = MPC_Script.SeenV6_MPC1;
        MPC2 = MPC_Script.SeenV6_MPC2;
        MPC3 = MPC_Script.SeenV6_MPC3;

        SeenMPC1Table = new NativeArray <V6>(MPC1.Count, Allocator.Persistent);
        for (int i = 0; i < MPC1.Count; i++)
        {
            SeenMPC1Table[i] = MPC1[i];
        }

        SeenMPC2Table = new NativeArray <V6>(MPC2.Count, Allocator.Persistent);
        for (int i = 0; i < MPC2.Count; i++)
        {
            SeenMPC2Table[i] = MPC2[i];
        }

        SeenMPC3Table = new NativeArray <V6>(MPC3.Count, Allocator.Persistent);
        for (int i = 0; i < MPC3.Count; i++)
        {
            SeenMPC3Table[i] = MPC3[i];
        }

        // assigning sripts names to the Tx and Rx
        Tx_Seen_MPC_Script = Tx.GetComponent <Transceiver_Channel>();
        Tx_Antenna_pattern = Tx_Seen_MPC_Script.Antenna_pattern;
        Rx_Seen_MPC_Script = Rx.GetComponent <Transceiver_Channel>();
        Rx_Antenna_pattern = Rx_Seen_MPC_Script.Antenna_pattern;
    }
コード例 #3
0
    List <V7> temp_V7_list3 = new List <V7>(); // this list will be used for sorting

    // Start is called before the first frame update
    void Start()
    {
        old_position1 = transform.position; // antenna #1 position in the beginning
        // in x axis
        ant1_min_x = old_position1.x - Reachable_distance;
        ant1_max_x = old_position1.x + Reachable_distance;
        // in z axis
        ant1_min_z = old_position1.z - Reachable_distance;
        ant1_max_z = old_position1.z + Reachable_distance;

        ///////////////////////////////////////////////////////////////////////////////////
        /// Start reading data from other scripts
        ///////////////////////////////////////////////////////////////////////////////////
        // reading generated MPCs from the mpc spawner script
        GameObject          MPC_Spawner = GameObject.Find("Direct_Solution");
        Correcting_polygons MPC_Script  = MPC_Spawner.GetComponent <Correcting_polygons>();

        MPC1   = MPC_Script.SeenV6_MPC1;
        V7MPC1 = MPC_Script.SeenV7_MPC1;
        MPC2   = MPC_Script.SeenV6_MPC2;
        V7MPC2 = MPC_Script.SeenV7_MPC2;
        MPC3   = MPC_Script.SeenV6_MPC3;
        V7MPC3 = MPC_Script.SeenV7_MPC3;


        // sorted lists by x and z: MPC1
        byX_V7MPC1 = V7MPC1.OrderBy(Elm => Elm.CoordNorm.Coordinates.x).ToList();
        byZ_V7MPC1 = V7MPC1.OrderBy(Elm => Elm.CoordNorm.Coordinates.z).ToList();
        // sorted lists by x and z: MPC1
        byX_V7MPC2 = V7MPC2.OrderBy(Elm => Elm.CoordNorm.Coordinates.x).ToList();
        byZ_V7MPC2 = V7MPC2.OrderBy(Elm => Elm.CoordNorm.Coordinates.z).ToList();
        // sorted lists by x and z: MPC1
        byX_V7MPC3 = V7MPC3.OrderBy(Elm => Elm.CoordNorm.Coordinates.x).ToList();
        byZ_V7MPC3 = V7MPC3.OrderBy(Elm => Elm.CoordNorm.Coordinates.z).ToList();



        ///////////////////////////////////////////////////////////////////////////////////
        /// Finish reading data from other scripts
        ///////////////////////////////////////////////////////////////////////////////////

        ///////////////////////////////////////////////////////////////////////////////////
        // search for seen mpcs within the search area
        ///////////////////////////////////////////////////////////////////////////////////

        ///////////////////////////////////////////////////////////////////////////////////
        /// MPC1

        ///////////////////////////////////////////////////////////////////////////////////
        //Debug.Log("Check0");

        for (int i = 0; i < MPC1.Count; i++)
        {
            if ((MPC1[i].Coordinates.x > ant1_min_x) && (MPC1[i].Coordinates.x < ant1_max_x) && (MPC1[i].Coordinates.z > ant1_min_z) && (MPC1[i].Coordinates.z < ant1_max_z))
            {
                //inarea_MPC1.Add(i);
                V7 temp_V7 = new V7(MPC1[i], i);
                temp_V7_list1.Add(temp_V7);
                inarea_MPC1.Add(i);
            }
        }

        // finding edges of inarea_MPC1 in x and z directions
        List <V7> XsortV7 = temp_V7_list1.OrderBy(Elm => Elm.CoordNorm.Coordinates.x).ToList();
        List <V7> ZsortV7 = temp_V7_list1.OrderBy(Elm => Elm.CoordNorm.Coordinates.z).ToList();

        // finding elements indexes in the sorted lists
        // for MPC1
        XMIN_index1 = byX_V7MPC1.FindIndex(V7elm => V7elm.Number == XsortV7[0].Number);
        XMAX_index1 = byX_V7MPC1.FindIndex(V7elm => V7elm.Number == XsortV7[XsortV7.Count - 1].Number);
        ZMIN_index1 = byZ_V7MPC1.FindIndex(V7elm => V7elm.Number == ZsortV7[0].Number);
        ZMAX_index1 = byZ_V7MPC1.FindIndex(V7elm => V7elm.Number == ZsortV7[XsortV7.Count - 1].Number);

        ///////////////////////////////////////////////////////////////////////////////////
        /// MPC2
        ///////////////////////////////////////////////////////////////////////////////////

        for (int i = 0; i < MPC2.Count; i++)
        {
            if ((MPC2[i].Coordinates.x > ant1_min_x) && (MPC2[i].Coordinates.x < ant1_max_x) && (MPC2[i].Coordinates.z > ant1_min_z) && (MPC2[i].Coordinates.z < ant1_max_z))
            {
                //inarea_MPC1.Add(i);
                V7 temp_V7 = new V7(MPC2[i], i);
                temp_V7_list2.Add(temp_V7);
                inarea_MPC2.Add(i);
            }
        }

        // finding edges of inarea_MPC1 in x and z directions
        List <V7> XsortV7_2 = temp_V7_list2.OrderBy(Elm => Elm.CoordNorm.Coordinates.x).ToList();
        List <V7> ZsortV7_2 = temp_V7_list2.OrderBy(Elm => Elm.CoordNorm.Coordinates.z).ToList();

        // finding elements indexes in the sorted lists
        // for MPC2
        XMIN_index2 = byX_V7MPC2.FindIndex(V7elm => V7elm.Number == XsortV7_2[0].Number);
        XMAX_index2 = byX_V7MPC2.FindIndex(V7elm => V7elm.Number == XsortV7_2[XsortV7_2.Count - 1].Number);
        ZMIN_index2 = byZ_V7MPC2.FindIndex(V7elm => V7elm.Number == ZsortV7_2[0].Number);
        ZMAX_index2 = byZ_V7MPC2.FindIndex(V7elm => V7elm.Number == ZsortV7_2[XsortV7_2.Count - 1].Number);

        ///////////////////////////////////////////////////////////////////////////////////
        /// MPC3
        ///////////////////////////////////////////////////////////////////////////////////

        for (int i = 0; i < MPC3.Count; i++)
        {
            if ((MPC3[i].Coordinates.x > ant1_min_x) && (MPC3[i].Coordinates.x < ant1_max_x) && (MPC3[i].Coordinates.z > ant1_min_z) && (MPC3[i].Coordinates.z < ant1_max_z))
            {
                //inarea_MPC1.Add(i);
                V7 temp_V7 = new V7(MPC3[i], i);
                temp_V7_list3.Add(temp_V7);
                inarea_MPC3.Add(i);
            }
        }

        // finding edges of inarea_MPC1 in x and z directions
        List <V7> XsortV7_3 = temp_V7_list3.OrderBy(Elm => Elm.CoordNorm.Coordinates.x).ToList();
        List <V7> ZsortV7_3 = temp_V7_list3.OrderBy(Elm => Elm.CoordNorm.Coordinates.z).ToList();

        // finding elements indexes in the sorted lists
        // for MPC3
        XMIN_index3 = byX_V7MPC3.FindIndex(V7elm => V7elm.Number == XsortV7_3[0].Number);
        XMAX_index3 = byX_V7MPC3.FindIndex(V7elm => V7elm.Number == XsortV7_3[XsortV7_3.Count - 1].Number);
        ZMIN_index3 = byZ_V7MPC3.FindIndex(V7elm => V7elm.Number == ZsortV7_3[0].Number);
        ZMAX_index3 = byZ_V7MPC3.FindIndex(V7elm => V7elm.Number == ZsortV7_3[XsortV7_3.Count - 1].Number);
    }
コード例 #4
0
    // Start is called before the first frame update
    void Start()
    {
        old_position1 = transform.position; // antenna #1 position in the beginning
        // in x axis
        // for MPC1 and DMC
        ant1_min_x1 = old_position1.x - ReachableDistance;
        ant1_max_x1 = old_position1.x + ReachableDistance;
        // for MPC2
        ant1_min_x2 = old_position1.x - ReachableDistance / 2;
        ant1_max_x2 = old_position1.x + ReachableDistance / 2;
        // for MPC3
        ant1_min_x3 = old_position1.x - ReachableDistance / 3;
        ant1_max_x3 = old_position1.x + ReachableDistance / 3;

        // in z axis
        // for MPC1 and DMC
        ant1_min_z1 = old_position1.z - ReachableDistance;
        ant1_max_z1 = old_position1.z + ReachableDistance;
        // for MPC2
        ant1_min_z2 = old_position1.z - ReachableDistance / 2;
        ant1_max_z2 = old_position1.z + ReachableDistance / 2;
        // for MPC3
        ant1_min_z3 = old_position1.z - ReachableDistance / 3;
        ant1_max_z3 = old_position1.z + ReachableDistance / 3;

        ///////////////////////////////////////////////////////////////////////////////////
        /// Start reading data from other scripts
        ///////////////////////////////////////////////////////////////////////////////////
        // reading generated MPCs from the mpc spawner script
        GameObject          MPC_Spawner = GameObject.Find("Direct_Solution");
        Correcting_polygons MPC_Script  = MPC_Spawner.GetComponent <Correcting_polygons>();

        DMC    = MPC_Script.SeenV6_DMC;
        V7DMC  = MPC_Script.SeenV7_DMC;
        MPC1   = MPC_Script.SeenV6_MPC1;
        V7MPC1 = MPC_Script.SeenV7_MPC1;
        MPC2   = MPC_Script.SeenV6_MPC2;
        V7MPC2 = MPC_Script.SeenV7_MPC2;
        MPC3   = MPC_Script.SeenV6_MPC3;
        V7MPC3 = MPC_Script.SeenV7_MPC3;


        // sorted lists by x and z: DMC
        byX_V7DMC = V7DMC.OrderBy(Elm => Elm.CoordNorm.Coordinates.x).ToList();
        byZ_V7DMC = V7DMC.OrderBy(Elm => Elm.CoordNorm.Coordinates.z).ToList();
        // sorted lists by x and z: MPC1
        byX_V7MPC1 = V7MPC1.OrderBy(Elm => Elm.CoordNorm.Coordinates.x).ToList();
        byZ_V7MPC1 = V7MPC1.OrderBy(Elm => Elm.CoordNorm.Coordinates.z).ToList();
        // sorted lists by x and z: MPC1
        byX_V7MPC2 = V7MPC2.OrderBy(Elm => Elm.CoordNorm.Coordinates.x).ToList();
        byZ_V7MPC2 = V7MPC2.OrderBy(Elm => Elm.CoordNorm.Coordinates.z).ToList();
        // sorted lists by x and z: MPC1
        //float startTime_org = Time.realtimeSinceStartup;
        byX_V7MPC3 = V7MPC3.OrderBy(ASD => ASD.CoordNorm.Coordinates.x).ToList();
        //Debug.Log("Check Time Org Sort: " + ((Time.realtimeSinceStartup - startTime_org) * 1000000f) + " microsec");
        byZ_V7MPC3 = V7MPC3.OrderBy(QWE => QWE.CoordNorm.Coordinates.z).ToList();


        /*
         * byX_V7MPC3 = V7MPC3;//.OrderBy(ASD => ASD.CoordNorm.Coordinates.x).ToList();
         * SortV7byX sortV7ByX = new SortV7byX();
         * byX_V7MPC3.Sort(sortV7ByX);
         *
         * float startTime_upd = Time.realtimeSinceStartup;
         * byZ_V7MPC3 = V7MPC3;//.OrderBy(QWE => QWE.CoordNorm.Coordinates.z).ToList();
         * SortV7byZ sortV7ByZ = new SortV7byZ();
         * byZ_V7MPC3.Sort(sortV7ByZ);
         * Debug.Log("Check Time Upd Sort: " + ((Time.realtimeSinceStartup - startTime_upd) * 1000000f) + " microsec");
         */

        ///////////////////////////////////////////////////////////////////////////////////
        /// Finish reading data from other scripts
        ///////////////////////////////////////////////////////////////////////////////////

        ///////////////////////////////////////////////////////////////////////////////////
        // search for seen mpcs within the search area
        ///////////////////////////////////////////////////////////////////////////////////

        ///////////////////////////////////////////////////////////////////////////////////
        /// DMC

        ///////////////////////////////////////////////////////////////////////////////////
        //Debug.Log("Check0");

        for (int i = 0; i < DMC.Count; i++)
        {
            if ((DMC[i].Coordinates.x > ant1_min_x1) && (DMC[i].Coordinates.x < ant1_max_x1) && (DMC[i].Coordinates.z > ant1_min_z1) && (DMC[i].Coordinates.z < ant1_max_z1))
            {
                //inarea_MPC1.Add(i);
                V7 temp_V7 = new V7(DMC[i], i);
                temp_V7_list0.Add(temp_V7);
                inarea_DMC.Add(i);
            }
        }

        // finding edges of inarea_MPC1 in x and z directions
        List <V7> XsortV7_0 = temp_V7_list0.OrderBy(Elm => Elm.CoordNorm.Coordinates.x).ToList();
        List <V7> ZsortV7_0 = temp_V7_list0.OrderBy(Elm => Elm.CoordNorm.Coordinates.z).ToList();

        // finding elements indexes in the sorted lists
        // for MPC1
        XMIN_index0 = byX_V7DMC.FindIndex(V7elm => V7elm.Number == XsortV7_0[0].Number);
        XMAX_index0 = byX_V7DMC.FindIndex(V7elm => V7elm.Number == XsortV7_0[XsortV7_0.Count - 1].Number);
        ZMIN_index0 = byZ_V7DMC.FindIndex(V7elm => V7elm.Number == ZsortV7_0[0].Number);
        ZMAX_index0 = byZ_V7DMC.FindIndex(V7elm => V7elm.Number == ZsortV7_0[XsortV7_0.Count - 1].Number);


        ///////////////////////////////////////////////////////////////////////////////////
        /// MPC1

        ///////////////////////////////////////////////////////////////////////////////////
        //Debug.Log("Check0");

        for (int i = 0; i < MPC1.Count; i++)
        {
            if ((MPC1[i].Coordinates.x > ant1_min_x1) && (MPC1[i].Coordinates.x < ant1_max_x1) && (MPC1[i].Coordinates.z > ant1_min_z1) && (MPC1[i].Coordinates.z < ant1_max_z1))
            {
                //inarea_MPC1.Add(i);
                V7 temp_V7 = new V7(MPC1[i], i);
                temp_V7_list1.Add(temp_V7);
                inarea_MPC1.Add(i);
            }
        }

        // finding edges of inarea_MPC1 in x and z directions
        List <V7> XsortV7 = temp_V7_list1.OrderBy(Elm => Elm.CoordNorm.Coordinates.x).ToList();
        List <V7> ZsortV7 = temp_V7_list1.OrderBy(Elm => Elm.CoordNorm.Coordinates.z).ToList();

        // finding elements indexes in the sorted lists
        // for MPC1
        XMIN_index1 = byX_V7MPC1.FindIndex(V7elm => V7elm.Number == XsortV7[0].Number);
        XMAX_index1 = byX_V7MPC1.FindIndex(V7elm => V7elm.Number == XsortV7[XsortV7.Count - 1].Number);
        ZMIN_index1 = byZ_V7MPC1.FindIndex(V7elm => V7elm.Number == ZsortV7[0].Number);
        ZMAX_index1 = byZ_V7MPC1.FindIndex(V7elm => V7elm.Number == ZsortV7[XsortV7.Count - 1].Number);

        ///////////////////////////////////////////////////////////////////////////////////
        /// MPC2
        ///////////////////////////////////////////////////////////////////////////////////

        for (int i = 0; i < MPC2.Count; i++)
        {
            if ((MPC2[i].Coordinates.x > ant1_min_x2) && (MPC2[i].Coordinates.x < ant1_max_x2) && (MPC2[i].Coordinates.z > ant1_min_z2) && (MPC2[i].Coordinates.z < ant1_max_z2))
            {
                //inarea_MPC1.Add(i);
                V7 temp_V7 = new V7(MPC2[i], i);
                temp_V7_list2.Add(temp_V7);
                inarea_MPC2.Add(i);
            }
        }

        // finding edges of inarea_MPC1 in x and z directions
        List <V7> XsortV7_2 = temp_V7_list2.OrderBy(Elm => Elm.CoordNorm.Coordinates.x).ToList();
        List <V7> ZsortV7_2 = temp_V7_list2.OrderBy(Elm => Elm.CoordNorm.Coordinates.z).ToList();

        // finding elements indexes in the sorted lists
        // for MPC2
        XMIN_index2 = byX_V7MPC2.FindIndex(V7elm => V7elm.Number == XsortV7_2[0].Number);
        XMAX_index2 = byX_V7MPC2.FindIndex(V7elm => V7elm.Number == XsortV7_2[XsortV7_2.Count - 1].Number);
        ZMIN_index2 = byZ_V7MPC2.FindIndex(V7elm => V7elm.Number == ZsortV7_2[0].Number);
        ZMAX_index2 = byZ_V7MPC2.FindIndex(V7elm => V7elm.Number == ZsortV7_2[XsortV7_2.Count - 1].Number);

        ///////////////////////////////////////////////////////////////////////////////////
        /// MPC3
        ///////////////////////////////////////////////////////////////////////////////////

        for (int i = 0; i < MPC3.Count; i++)
        {
            if ((MPC3[i].Coordinates.x > ant1_min_x3) && (MPC3[i].Coordinates.x < ant1_max_x3) && (MPC3[i].Coordinates.z > ant1_min_z3) && (MPC3[i].Coordinates.z < ant1_max_z3))
            {
                //inarea_MPC1.Add(i);
                V7 temp_V7 = new V7(MPC3[i], i);
                temp_V7_list3.Add(temp_V7);
                inarea_MPC3.Add(i);
            }
        }

        // finding edges of inarea_MPC1 in x and z directions
        List <V7> XsortV7_3 = temp_V7_list3.OrderBy(Elm => Elm.CoordNorm.Coordinates.x).ToList();
        List <V7> ZsortV7_3 = temp_V7_list3.OrderBy(Elm => Elm.CoordNorm.Coordinates.z).ToList();

        // finding elements indexes in the sorted lists
        // for MPC3
        XMIN_index3 = byX_V7MPC3.FindIndex(V7elm => V7elm.Number == XsortV7_3[0].Number);
        XMAX_index3 = byX_V7MPC3.FindIndex(V7elm => V7elm.Number == XsortV7_3[XsortV7_3.Count - 1].Number);
        ZMIN_index3 = byZ_V7MPC3.FindIndex(V7elm => V7elm.Number == ZsortV7_3[0].Number);
        ZMAX_index3 = byZ_V7MPC3.FindIndex(V7elm => V7elm.Number == ZsortV7_3[XsortV7_3.Count - 1].Number);
    }
コード例 #5
0
ファイル: LookUpTableGen.cs プロジェクト: Urankhai/3DChaSi
    // Start is called before the first frame update
    void Start()
    {
        GameObject          MPC_Spawner = GameObject.Find("Direct_Solution");
        Correcting_polygons MPC_Script  = MPC_Spawner.GetComponent <Correcting_polygons>();
        List <V6>           MPC1        = MPC_Script.SeenV6_MPC1;
        List <V6>           MPC2        = MPC_Script.SeenV6_MPC2;
        List <V6>           MPC3        = MPC_Script.SeenV6_MPC3;

        Debug.Log("LookUpTableGen Script");
        Debug.Log("#MPC1 = " + MPC1.Count + "; #MPC2 = " + MPC2.Count + "; #MPC3 = " + MPC3.Count);


        string do_we_need_third_order = "n";

        // for MPC1, we do not need to have a LookUp table
        // LookUpTable for MPC2
        double angle_threshold2 = 0.1;
        int    level_start2     = 0;

        for (int i = 0; i < MPC2.Count; i++)
        {
            List <int>     tempV6list    = new List <int>();
            List <GeoComp> temp_goeComps = new List <GeoComp>();
            int            temp_seen_mpc = 0;
            for (int ii = 0; ii < MPC2.Count; ii++)
            {
                if (i != ii)
                {
                    Vector3 temp_direction = (MPC2[ii].Coordinates - MPC2[i].Coordinates).normalized;
                    //RaycastHit hit;
                    //if (Physics.Linecast(MPC2[i].Coordinates, MPC2[ii].Coordinates, out hit))
                    //{ Debug.Log("name of the hit object" + hit.transform.name); }
                    if (!Physics.Linecast(MPC2[i].Coordinates, MPC2[ii].Coordinates))
                    {
                        if (Vector3.Dot(temp_direction, MPC2[ii].Normal) < -angle_threshold2 && Vector3.Dot(temp_direction, MPC2[i].Normal) > angle_threshold2)
                        {
                            float dist = (MPC3[ii].Coordinates - MPC3[i].Coordinates).magnitude;
                            if (dist < MaxSeenDistanceMPC2)
                            {
                                tempV6list.Add(ii);
                                temp_seen_mpc += 1;


                                float   aod       = Mathf.Acos(Vector3.Dot(temp_direction, MPC2[i].Normal));
                                float   aoa       = Mathf.Acos(-Vector3.Dot(temp_direction, MPC2[ii].Normal));
                                GeoComp all_comps = new GeoComp(ii, dist, aod, aoa);

                                Linear_GC2.Add(all_comps);

                                temp_goeComps.Add(all_comps);

                                if (do_we_need_third_order == "y")
                                {
                                    if (i == 20)
                                    {
                                        Debug.DrawLine(MPC2[i].Coordinates, MPC2[ii].Coordinates, Color.yellow, 5.0f);

                                        Debug.Log("The normal of seen mpc " + MPC2[ii].Normal + "; the connecting line direction " + temp_direction);
                                        Debug.DrawLine(MPC2[ii].Coordinates, MPC2[ii].Coordinates + temp_direction * 3.0f, Color.green, 5.0f);
                                        Debug.DrawLine(MPC2[ii].Coordinates, MPC2[ii].Coordinates + MPC2[ii].Normal * 3.0f, Color.red, 5.0f);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            LUT2.Add(tempV6list);
            GC2.Add(temp_goeComps);

            Vector2Int layer_edges = new Vector2Int(level_start2, level_start2 + temp_seen_mpc - 1);
            Indexes_GC2.Add(layer_edges);
            level_start2 += temp_seen_mpc;
            if (MaxLengthOfSeenMPC2Lists < temp_seen_mpc)
            {
                MaxLengthOfSeenMPC2Lists = temp_seen_mpc;
            }
        }



        // LookUpTable for MPC3
        double angle_threshold3 = 0.3;
        int    level_start3     = 0;

        for (int i = 0; i < MPC3.Count; i++)
        {
            List <int>     tempV6list    = new List <int>();
            List <GeoComp> temp_goeComps = new List <GeoComp>();

            int temp_seen_mpc = 0;
            for (int ii = 0; ii < MPC3.Count; ii++)
            {
                if (i != ii)
                {
                    Vector3 temp_direction = (MPC3[ii].Coordinates - MPC3[i].Coordinates).normalized;
                    if (!Physics.Linecast(MPC3[i].Coordinates, MPC3[ii].Coordinates))
                    {
                        if (Vector3.Dot(temp_direction, MPC3[ii].Normal) < -angle_threshold3 && Vector3.Dot(temp_direction, MPC3[i].Normal) > angle_threshold3)
                        {
                            float dist = (MPC3[ii].Coordinates - MPC3[i].Coordinates).magnitude;
                            if (dist < MaxSeenDistanceMPC3)
                            {
                                tempV6list.Add(ii);
                                temp_seen_mpc += 1;

                                float   aod       = Mathf.Acos(Vector3.Dot(temp_direction, MPC3[i].Normal));
                                float   aoa       = Mathf.Acos(-Vector3.Dot(temp_direction, MPC3[ii].Normal));
                                GeoComp all_comps = new GeoComp(ii, dist, aod, aoa);
                                Linear_GC3.Add(all_comps);
                                temp_goeComps.Add(all_comps);

                                if (do_we_need_third_order == "y")
                                {
                                    if (i == 20)
                                    {
                                        Debug.DrawLine(MPC3[i].Coordinates, MPC3[ii].Coordinates, Color.yellow, 5.0f);

                                        Debug.Log("The normal of seen mpc " + MPC3[ii].Normal + "; the connecting line direction " + temp_direction);
                                        Debug.DrawLine(MPC3[ii].Coordinates, MPC3[ii].Coordinates + temp_direction * 3.0f, Color.green, 5.0f);
                                        Debug.DrawLine(MPC3[ii].Coordinates, MPC3[ii].Coordinates + MPC3[ii].Normal * 3.0f, Color.red, 5.0f);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            LUT3.Add(tempV6list);
            GC3.Add(temp_goeComps);

            Vector2Int layer_edges = new Vector2Int(level_start3, level_start3 + temp_seen_mpc - 1);
            Indexes_GC3.Add(layer_edges);
            level_start3 += temp_seen_mpc;
            if (MaxLengthOfSeenMPC3Lists < temp_seen_mpc)
            {
                MaxLengthOfSeenMPC3Lists = temp_seen_mpc;
            }
        }
    }
コード例 #6
0
ファイル: ChenGenParallel.cs プロジェクト: Urankhai/3DChaSi
    // Start is called before the first frame update
    void Start()
    {
        /// for Fourier transform
        X_inputValues = new double[H.Length];
        for (int i = 0; i < H.Length; i++)
        {
            X_inputValues[i] = i;
        }

        // ground reflection
        Z = (float)Math.Sqrt(RelativePermitivity - 1);

        // finding the script
        GameObject     LookUpT    = GameObject.Find("LookUpTables");
        LookUpTableGen LUT_Script = LookUpT.GetComponent <LookUpTableGen>();

        // this may not be used
        // GlobeCom2 = LUT_Script.GC2; // coordinates, normals, distances, departing and arriving angles
        // GlobeCom3 = LUT_Script.GC3; // coordinates, normals, distances, departing and arriving angles

        // reading info about MPC2
        LinearGlobeCom2          = LUT_Script.Linear_GC2;
        IndexesGlobeCom2         = LUT_Script.Indexes_GC2;
        MaxLengthOfSeenMPC2Lists = LUT_Script.MaxLengthOfSeenMPC2Lists;

        // initialize the H_parallel NativeArray
        H_LoS             = new NativeArray <System.Numerics.Complex>(H.Length, Allocator.Persistent); // Check if one array can be used by a number of jobs and correctly changed
        flag_LoS          = 0;                                                                         // flag will be needed for the edge effect
        H_MPC1            = new NativeArray <System.Numerics.Complex>(H.Length, Allocator.Persistent);
        H_MPC2            = new NativeArray <System.Numerics.Complex>(H.Length, Allocator.Persistent);
        H_MPC3            = new NativeArray <System.Numerics.Complex>(H.Length, Allocator.Persistent);
        Subcarriers       = new NativeArray <float>(H.Length, Allocator.Persistent);
        InverseWavelength = new NativeArray <float>(H.Length, Allocator.Persistent);
        for (int i = 0; i < H.Length; i++)
        {
            H[i]                 = new System.Numerics.Complex(0, 0);
            H_pure[i]            = new System.Numerics.Complex(0, 0);
            H_noise[i]           = new System.Numerics.Complex(0, 0);
            H_LoS[i]             = new System.Numerics.Complex(0, 0);
            H_MPC1[i]            = new System.Numerics.Complex(0, 0);
            H_MPC2[i]            = new System.Numerics.Complex(0, 0);
            H_MPC3[i]            = new System.Numerics.Complex(0, 0);
            Subcarriers[i]       = CarrierFrequency + fsubcarriers * (i + 1);
            InverseWavelength[i] = Subcarriers[i] / SpeedofLight;
        }

        // test allocation nativearrays
        LookUpTable2   = new NativeArray <GeoComp>(LinearGlobeCom2.Count, Allocator.Persistent);
        LookUpTable2ID = new NativeArray <Vector2Int>(IndexesGlobeCom2.Count, Allocator.Persistent);

        for (int i = 0; i < LinearGlobeCom2.Count; i++)
        {
            LookUpTable2[i] = LinearGlobeCom2[i];
        }
        for (int i = 0; i < IndexesGlobeCom2.Count; i++)
        {
            LookUpTable2ID[i] = IndexesGlobeCom2[i];
        }

        // reading info about MPC3
        LinearGlobeCom3          = LUT_Script.Linear_GC3;
        IndexesGlobeCom3         = LUT_Script.Indexes_GC3;
        MaxLengthOfSeenMPC3Lists = LUT_Script.MaxLengthOfSeenMPC3Lists;

        LookUpTable3   = new NativeArray <GeoComp>(LinearGlobeCom3.Count, Allocator.Persistent);
        LookUpTable3ID = new NativeArray <Vector2Int>(IndexesGlobeCom3.Count, Allocator.Persistent);

        for (int i = 0; i < LinearGlobeCom3.Count; i++)
        {
            LookUpTable3[i] = LinearGlobeCom3[i];
        }
        for (int i = 0; i < IndexesGlobeCom3.Count; i++)
        {
            LookUpTable3ID[i] = IndexesGlobeCom3[i];
        }
        // test allocation nativearrays



        GameObject          MPC_Spawner = GameObject.Find("Direct_Solution");
        Correcting_polygons MPC_Script  = MPC_Spawner.GetComponent <Correcting_polygons>();

        MPC1 = MPC_Script.SeenV6_MPC1;
        MPC2 = MPC_Script.SeenV6_MPC2;
        MPC3 = MPC_Script.SeenV6_MPC3;

        SeenMPC1Table = new NativeArray <V6>(MPC1.Count, Allocator.Persistent);
        for (int i = 0; i < MPC1.Count; i++)
        {
            SeenMPC1Table[i] = MPC1[i];
        }

        SeenMPC2Table = new NativeArray <V6>(MPC2.Count, Allocator.Persistent);
        for (int i = 0; i < MPC2.Count; i++)
        {
            SeenMPC2Table[i] = MPC2[i];
        }

        SeenMPC3Table = new NativeArray <V6>(MPC3.Count, Allocator.Persistent);
        for (int i = 0; i < MPC3.Count; i++)
        {
            SeenMPC3Table[i] = MPC3[i];
        }

        // assigning sripts names to the Tx and Rx
        Tx_Seen_MPC_Script = Tx.GetComponent <Transceiver_Channel>();
        Tx_Antenna_pattern = Tx_Seen_MPC_Script.Antenna_pattern;
        Rx_Seen_MPC_Script = Rx.GetComponent <Transceiver_Channel>();
        Rx_Antenna_pattern = Rx_Seen_MPC_Script.Antenna_pattern;
    }