예제 #1
0
        public static double LiczenieOdleglosc(PunktK p1, Punkt p2)
        {
            var x = Math.Pow(p1.X1 - p2.X1, 2);

            var x2 = Math.Pow(p1.X2 - p2.X2, 2);

            double a = Math.Sqrt(x + x2);

            return(a);
        }
예제 #2
0
        public static void NadanieGrupy(ref Punkt punkt, List <PunktK> kpunkty)
        {
            Dictionary <double, PunktK> d = new Dictionary <double, PunktK>();

            foreach (var kpunkt in kpunkty)
            {
                double od = LiczenieOdleglosc(kpunkt, punkt);

                while (d.ContainsKey(od))
                {
                    od = od + 0.000001;
                }

                d.Add(od, kpunkt);
            }

            var g = d.First(k => k.Key == d.Keys.Min()).Value.Grupa;

            punkt.Grupa = g;
        }