private void createRays()
    {
        //makes all the rays and then adds them to the list

        Transform child = this.transform.Find("Starting Point");

        if (child == null)
        {
            child = new GameObject("Starting Point").transform;

            child.SetParent(this.transform);
            child.localPosition = new Vector3(0, .55f, 0);
            child.rotation      = this.transform.rotation;
        }

        List <List <Vector2> > allLines = this.getPoints(child.position, child.up);

        GameObject rayPrefab = (GameObject)SceneResouces.SceneObjects["Default"][typeof(GameObject)]["Ray"];

        foreach (List <Vector2> lines in allLines)
        {
            GameObject rayGO = Instantiate(rayPrefab);
            rayGO.transform.SetParent(this.transform);
            rayGO.transform.position = Vector3.zero;
            LineController lc = rayGO.GetComponent <LineController>();
            lc.setPoints(VertexExtension.toVector3Array(lines.ToArray()));
            this.lineControllers.Add(lc);
        }
    }
Ejemplo n.º 2
0
        /// <summary>
        /// Return statistics about vertex
        /// </summary>
        /// <param name="v">vertex</param>
        /// <returns></returns>
        public static Statistic GetStatistic(Vertex v)
        {
            Statistic ret = new Statistic(Setup.Dim - DimOffset);

            Facility fac = v.Facility;

            if (fac == null)
            {
                ret.HasFacility = false;
            }
            else
            {
                ret.HasFacility = true;

                Vertex     centre  = Program.Points[fac.VertexIndex];
                List <int> clients = fac.VertexIndices;

                ret.CentreCoord = centre.coords;
                ret.Clients     = clients.Count;

                foreach (int c in clients)
                {
                    Vertex cl = Program.Points[c];
                    double d  = VertexExtension.DistanceBetween(centre, cl, CoordX, CoordY);

                    if (d > ret.MaxDistance)
                    {
                        ret.MaxDistance = d;

                        ret.IndexMaxDist = c;
                    }

                    for (int i = 0; i < Setup.Dim - DimOffset; ++i)
                    {
                        int of = i + DimOffset;

                        if (ret.Max[i] < cl[of])
                        {
                            ret.Max[i]      = cl[of];
                            ret.IndexMax[i] = c;
                        }

                        if (ret.Min[i] > cl[of])
                        {
                            ret.Min[i] = cl[of];

                            ret.IndexMax[i] = c;
                        }
                    }
                }
            }

            return(ret);
        }
Ejemplo n.º 3
0
        public static bool Clust()
        {
            BoundingBox     Bound;
            List <Facility> Facility;

            // read data
            Vertex[] Points = LoadLine.Load(Setup.InputPath, out Bound);

            // setup dimension of points
            Setup.Dim = Points[0].Dimension;

            FacilityLocation fac = new FacilityLocation();

            // setup clustering properties
            Vertex.CoordWeights  = Setup.ValueDim;
            Vertex.CoordBorder   = Setup.Border;
            Vertex.BorderMin     = Setup.BorderMin;
            Vertex.BorderPercent = Setup.BorderPercent;


            // setup metric
            VertexExtension.SetLineMetric();

            // start clustering
            fac.ComputeClustering(Points, Bound);

            // get index of facilities
            int[] indexCentre = fac.GetAllFacilities();

            // create array for facilities
            Vertex[] centre = new Vertex[indexCentre.Length];

            // insert facilities vertices into array
            for (int f = 0; f < centre.Length; f++)
            {
                centre[f] = Points[indexCentre[f]];
            }

            Facility = fac.Facilities;
            Analysis.SaveSite(ref Points, ref Facility, Setup.OutPath, Setup.SizeFilter);

            return(false);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Calculate maximal and minimal values of particular vertices
        /// </summary>
        /// <param name="v">list of vertices</param>
        /// <param name="f">list of facilities</param>
        /// <returns></returns>
        public static Statistic GetGeoStatistic(ref Vertex[] v, ref List <Facility> f)
        {
            Statistic ret = new Statistic(Setup.Dim - DimOffset);

            foreach (Facility fac in f)
            {
                Vertex     centre  = v[fac.VertexIndex];
                List <int> clients = fac.VertexIndices;

                foreach (int c in clients)
                {
                    double d = VertexExtension.DistanceBetween(centre, v[c], CoordX, CoordY);

                    if (d > ret.MaxDistance)
                    {
                        ret.MaxDistance = d;

                        ret.IndexMaxDist = c;
                    }

                    for (int i = 0; i < Setup.Dim - DimOffset; ++i)
                    {
                        int of = i + DimOffset;

                        if (ret.Max[i] < v[c][of])
                        {
                            ret.Max[i] = v[c][of];

                            ret.IndexMax[i] = c;
                        }

                        if (ret.Min[i] > v[c][of])
                        {
                            ret.Min[i] = v[c][of];

                            ret.IndexMax[i] = c;
                        }
                    }
                }
            }
            return(ret);
        }