Example #1
0
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            if (selectedGateway == null)
            {
                return;
            }

            MessageBoxResult result = MessageBox.Show("Are you sure to delete this?", "WARNING!", MessageBoxButton.YesNo);

            if (result == MessageBoxResult.No)
            {
                return;
            }

            try
            {
                Mouse.OverrideCursor = Cursors.Wait;
                Gateway gateway = (Gateway)lstGateways.SelectedItem;
                IndoorPositioningClient.DeleteGateway(gateway);

                /* remove selected item */
                selectedGateway = null;
                selectedIndex   = 0;
                /* Load the list again */
                Load();
                Mouse.OverrideCursor = Cursors.Arrow;
            }
            catch (Exception ex)
            {
                Mouse.OverrideCursor = Cursors.Arrow;
                MessageBox.Show(ex.ToString());
            }
        }
Example #2
0
        private void btnClearAllBeacons_Click(object sender, RoutedEventArgs e)
        {
            MessageBoxResult result = MessageBox.Show("Are you sure to delete this?", "WARNING!", MessageBoxButton.YesNo);

            if (result == MessageBoxResult.No)
            {
                return;
            }

            try
            {
                Mouse.OverrideCursor = Cursors.Wait;
                foreach (Beacon beacon in lstBeacons.Items)
                {
                    /* remove all unknown beacons from the server */
                    if ("unknown".Equals(beacon.Name.ToLower()))
                    {
                        IndoorPositioningClient.DeleteBeacon(beacon);
                    }
                }

                /* remove selected item */
                selectedBeacon = null;
                selectedIndex  = 0;
                /* Load the list again */
                Load();
                Mouse.OverrideCursor = Cursors.Arrow;
            }
            catch (Exception ex)
            {
                Mouse.OverrideCursor = Cursors.Arrow;
                MessageBox.Show(ex.ToString());
            }
        }
Example #3
0
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Mouse.OverrideCursor = Cursors.Wait;
                /* Create a new environment */
                Environment environment = new Environment()
                {
                    Name   = txtName.Text,
                    Width  = int.Parse(txtWidth.Text),
                    Height = int.Parse(txtHeight.Text),
                    DistanceBetweenReferencePoints = int.Parse(txtDistanceBetweenRefPoints.Text),
                    Timestamp = DateTime.Now,
                };
                IndoorPositioningClient.AddEnvironment(environment);

                /* Load the list again */
                Load();
                Mouse.OverrideCursor = Cursors.Arrow;
            }
            catch (Exception ex)
            {
                Mouse.OverrideCursor = Cursors.Arrow;
                MessageBox.Show(ex.ToString());
            }
        }
Example #4
0
        private void Positioning()
        {
            try
            {
                /* Load fingerprinting data from the server */
                List <AdjustedFingerprinting> fingerprintings = IndoorPositioningClient.GetFingerprintings(environment.EnvironmentId);
                /* Disappear the loading splash screen */
                Application.Current.Dispatcher.Invoke(() => ShowLoadingScreen = false);

                while (PositioningActivated)
                {
                    try
                    {
                        Coordinate coordinate = new Coordinate();
                        /* Run KNNClassifier */
                        if (SelectedAlgorithmIndex == 0)
                        {
                            coordinate = Positioning_Knn(fingerprintings);
                        }
                        else if (SelectedAlgorithmIndex == 1)
                        {
                            coordinate = Positioning_KnnProximity(fingerprintings);
                        }
                        else if (SelectedAlgorithmIndex == 2)
                        {
                            coordinate = Positioning_Proximity();
                        }
                        else
                        {
                            throw new Exception("Invalid algorithm");
                        }

                        /* Success process, clear error message if any */
                        Application.Current.Dispatcher.Invoke(() => txtAlert.Text = "");

                        /* Add the beacon localized onto the screen */
                        Application.Current.Dispatcher.Invoke(() => environmentShape.MoveBeacon(coordinate.Xaxis, coordinate.Yaxis));
                    }
                    catch (ThreadAbortException) { break; }
                    catch (Exception ex)
                    {
                        Application.Current.Dispatcher.Invoke(() => txtAlert.Text = ex.Message);
                    }
                    finally
                    {
                        /* Every second, query the server for the RSSI values read by the gateways */
                        Thread.Sleep(2000);
                    }
                }
            }
            catch (ThreadAbortException) { /* do nothing */ }
            catch (Exception ex)
            {
                Application.Current.Dispatcher.Invoke(() => MessageBox.Show(ex.ToString()));
            }
        }
        /* */
        private void DeactivateFingerprinting()
        {
            try
            {
                IndoorPositioningClient.SetModeAsIdle();

                /* Change the color of the fingerprinting ellipse */
                FingerprintingBrush = new SolidColorBrush(Colors.Red);
            }
            catch (Exception ex) { MessageBox.Show(ex.Message); }
        }
Example #6
0
        private void mnItemFingerprinting_Click(object sender, RoutedEventArgs e)
        {
            /* Set the mode as idle */
            try
            {
                IndoorPositioningClient.SetModeAsIdle();
            }
            catch (Exception ex) { MessageBox.Show(ex.Message); }

            DisposeContent();
            var screen = new FingerprintingScreen();

            content.Content = screen;
        }
        private void ActivateFingerprinting()
        {
            try
            {
                /* Send the mode changing request to the server */
                Environment env    = (Environment)cbEnvironments.SelectedItem;
                Beacon      beacon = (Beacon)cbBeacons.SelectedItem;
                IndoorPositioningClient.SetModeAsFingerprinting(beacon.BeaconId, env.EnvironmentId,
                                                                environmentShape.SelectedXaxis, environmentShape.SelectedYaxis);

                /* Change the color of the fingerprinting ellipse */
                FingerprintingBrush = new SolidColorBrush(Colors.Green);
            }
            catch (Exception ex) { MessageBox.Show(ex.Message); }
        }
Example #8
0
 private void StopPositioning()
 {
     try
     {
         IndoorPositioningClient.SetModeAsIdle();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     try { positioningThread.Abort(); }
     catch { }
     try { positioningThread = null; }
     catch { }
 }
 /* Load the list of environments from Server */
 private void Load()
 {
     try
     {
         Mouse.OverrideCursor       = Cursors.Wait;
         cbEnvironments.ItemsSource = IndoorPositioningClient.GetEnvironments();
         cbBeacons.ItemsSource      = IndoorPositioningClient.GetBeacons();
         Mouse.OverrideCursor       = Cursors.Arrow;
     }
     catch (Exception ex)
     {
         Mouse.OverrideCursor = Cursors.Arrow;
         MessageBox.Show(ex.ToString());
     }
 }
Example #10
0
        public MapScreen()
        {
            Initialized += MapScreen_Initialized;
            Loaded      += MapScreen_Loaded;

            InitializeComponent();

            DataContext = this;

            /* Set gateways of the environment */
            try
            {
                List <Gateway> gateways = IndoorPositioningClient.GetGateways();
                environmentShape.Gateways = gateways.ToArray();
            }
            catch (Exception ex) { MessageBox.Show(ex.ToString()); }
        }
Example #11
0
 private void Load()
 {
     try
     {
         Mouse.OverrideCursor    = Cursors.Wait;
         lstGateways.ItemsSource = IndoorPositioningClient.GetGateways();
         if (lstGateways.Items.Count > 0)
         {
             lstGateways.SelectedIndex = selectedIndex;
         }
         Mouse.OverrideCursor = Cursors.Arrow;
     }
     catch (Exception ex)
     {
         Mouse.OverrideCursor = Cursors.Arrow;
         MessageBox.Show(ex.ToString());
     }
 }
Example #12
0
        private Coordinate Positioning_Knn(List <AdjustedFingerprinting> fingerprintings)
        {
            /* run the knn classifier on the data */
            KnnClassifier classifier = new KnnClassifier();

            /* After fetching and processing the fingerprinting data, I am able to get the class count.
             * Basically, each of the reference point is a class to be classified to. */
            int numClasses   = IndoorPositioningClient.GetPoints(environment.EnvironmentId).Count;
            int gatewayCount = fingerprintings[0].RssiValueAndGateway.Count;

            /* get the Rssi values of the beacon in question from the server */
            RssiValue[] rssiValues = IndoorPositioningClient.GetRssi(gatewayCount);

            /* we will use also gateway count on the area as K constant */
            Coordinate coordinate = classifier.Classify(rssiValues, fingerprintings, numClasses, 3);

            return(coordinate);
        }
Example #13
0
        private void StartPositioning()
        {
            try
            {
                /* Change server mode into positioning */
                Beacon beacon = (Beacon)cbBeacons.SelectedItem;
                IndoorPositioningClient.SetModeAsPositioning(beacon.BeaconId);

                environment = (Environment)cbEnvironments.SelectedItem;

                positioningThread = new Thread(Positioning)
                {
                    IsBackground = true
                };
                positioningThread.Start();

                ShowLoadingScreen = true;
            }
            catch (Exception ex) { MessageBox.Show(ex.Message); }
        }
Example #14
0
        private void btnUpdate_Click(object sender, RoutedEventArgs e)
        {
            if (selectedEnvironment == null)
            {
                return;
            }

            try
            {
                Mouse.OverrideCursor = Cursors.Wait;
                IndoorPositioningClient.UpdateEnvironment(selectedEnvironment);

                /* Load the list again */
                Load();
                Mouse.OverrideCursor = Cursors.Arrow;
            }
            catch (Exception ex)
            {
                Mouse.OverrideCursor = Cursors.Arrow;
                MessageBox.Show(ex.ToString());
            }
        }
Example #15
0
        private void btnUpdate_Click(object sender, RoutedEventArgs e)
        {
            if (selectedGateway == null)
            {
                return;
            }

            try
            {
                Mouse.OverrideCursor = Cursors.Wait;
                IndoorPositioningClient.UpdateGateway(selectedGateway);

                /* Load the list again */
                Load();
                /* Select the same item from the list. */
                lstGateways.SelectedIndex = selectedIndex;
                Mouse.OverrideCursor      = Cursors.Arrow;
            }
            catch (Exception ex)
            {
                Mouse.OverrideCursor = Cursors.Arrow;
                MessageBox.Show(ex.ToString());
            }
        }
Example #16
0
        private Coordinate Positioning_Proximity()
        {
            List <Gateway> gateways = IndoorPositioningClient.GetGateways();

            /* get the Rssi values of the beacon in question from the server */
            RssiValue[] rssiValues = IndoorPositioningClient.GetRssi(gateways.Count);

            CoordinateAndDistance[] cooDist = new CoordinateAndDistance[gateways.Count];
            for (int i = 0; i < gateways.Count; i++)
            {
                cooDist[i] = new CoordinateAndDistance()
                {
                    coordinate = new Coordinate()
                    {
                        Xaxis = (int)GetGatewayXaxis(gateways[i]),
                        Yaxis = (int)GetGatewayYaxis(gateways[i]),
                    },
                    dist = rssiValues[i].Rssi
                };
            }

            Coordinate coordinateFirstAndSecondLine = new Coordinate();
            Coordinate coordinateFirstAndThirdLine  = new Coordinate();
            Coordinate coordinateSecondAndThirdLine = new Coordinate();

            /* Create a vector from the coordinates */
            /* Measure the first point of crossing the first and second line*/
            DoubleMatrix matrixFirstAndSecondLine = new DoubleMatrix(new double[, ]
            {
                {
                    cooDist[0].coordinate.Xaxis - cooDist[1].coordinate.Xaxis,
                    cooDist[0].coordinate.Yaxis - cooDist[1].coordinate.Yaxis
                },
                {
                    cooDist[0].coordinate.Xaxis - cooDist[2].coordinate.Xaxis,
                    cooDist[0].coordinate.Yaxis - cooDist[2].coordinate.Yaxis
                }
            });

            /* If the determinant value of the matrix is 0, it means this matrix cannot be inverted.
             * We can have the exact point values with one of the reference points. */
            if (NMathFunctions.Determinant(matrixFirstAndSecondLine) == 0)
            {
                return(cooDist[0].coordinate);
            }

            //matrixFirstAndSecondLine = matrixFirstAndSecondLine.Transform((p) => p * 2);
            DoubleMatrix inversedMatrixFirstAndSecondLine = NMathFunctions.Inverse(matrixFirstAndSecondLine);
            DoubleVector vectorFirstAndSecondLine         = new DoubleVector(new double[]
            {
                cooDist[0].coordinate.GetNormPow() - cooDist[1].coordinate.GetNormPow() - cooDist[0].GetDistPow() + cooDist[1].GetDistPow(),
                cooDist[0].coordinate.GetNormPow() - cooDist[2].coordinate.GetNormPow() - cooDist[0].GetDistPow() + cooDist[2].GetDistPow()
            });

            vectorFirstAndSecondLine = vectorFirstAndSecondLine.Transform((p) => p / 2);

            DoubleVector coordinateVectorFirstAndSecondLine = NMathFunctions.Product(inversedMatrixFirstAndSecondLine,
                                                                                     vectorFirstAndSecondLine);

            coordinateFirstAndSecondLine.Xaxis = (int)coordinateVectorFirstAndSecondLine[0];
            coordinateFirstAndSecondLine.Yaxis = (int)coordinateVectorFirstAndSecondLine[1];

            /* Measure the first point of crossing the first and third line*/
            DoubleMatrix matrixFirstAndThirdLine = new DoubleMatrix(new double[, ]
            {
                {
                    cooDist[0].coordinate.Xaxis - cooDist[1].coordinate.Xaxis,
                    cooDist[0].coordinate.Yaxis - cooDist[1].coordinate.Yaxis
                },
                {
                    cooDist[1].coordinate.Xaxis - cooDist[2].coordinate.Xaxis,
                    cooDist[1].coordinate.Yaxis - cooDist[2].coordinate.Yaxis
                }
            });

            /* If the determinant value of the matrix is 0, it means this matrix cannot be inverted.
             * We can have the exact point values with one of the reference points. */
            if (NMathFunctions.Determinant(matrixFirstAndThirdLine) == 0)
            {
                return(cooDist[0].coordinate);
            }

            //matrixFirstAndThirdLine = matrixFirstAndThirdLine.Transform((p) => p * 2);
            DoubleMatrix inversedMatrixFirstAndThirdLine = NMathFunctions.Inverse(matrixFirstAndThirdLine);
            DoubleVector vectorFirstAndThirdLine         = new DoubleVector(new double[]
            {
                cooDist[0].coordinate.GetNormPow() - cooDist[1].coordinate.GetNormPow() - cooDist[0].GetDistPow() + cooDist[1].GetDistPow(),
                cooDist[1].coordinate.GetNormPow() - cooDist[2].coordinate.GetNormPow() - cooDist[1].GetDistPow() + cooDist[2].GetDistPow()
            });

            vectorFirstAndThirdLine = vectorFirstAndThirdLine.Transform((p) => p / 2);

            DoubleVector coordinateVectorFirstAndThirdLine = NMathFunctions.Product(inversedMatrixFirstAndThirdLine,
                                                                                    vectorFirstAndThirdLine);

            coordinateFirstAndThirdLine.Xaxis = (int)coordinateVectorFirstAndThirdLine[0];
            coordinateFirstAndThirdLine.Yaxis = (int)coordinateVectorFirstAndThirdLine[1];

            /* Measure the first point of crossing the first and third line*/
            DoubleMatrix matrixSecondAndThirdLine = new DoubleMatrix(new double[, ]
            {
                {
                    cooDist[0].coordinate.Xaxis - cooDist[2].coordinate.Xaxis,
                    cooDist[0].coordinate.Yaxis - cooDist[2].coordinate.Yaxis
                },
                {
                    cooDist[1].coordinate.Xaxis - cooDist[2].coordinate.Xaxis,
                    cooDist[1].coordinate.Yaxis - cooDist[2].coordinate.Yaxis
                }
            });

            /* If the determinant value of the matrix is 0, it means this matrix cannot be inverted.
             * We can have the exact point values with one of the reference points. */
            if (NMathFunctions.Determinant(matrixSecondAndThirdLine) == 0)
            {
                return(cooDist[0].coordinate);
            }

            //matrixSecondAndThirdLine = matrixSecondAndThirdLine.Transform((p) => p * 2);
            DoubleMatrix inversedMatrixSecondAndThirdLine = NMathFunctions.Inverse(matrixSecondAndThirdLine);
            DoubleVector vectorSecondAndThirdLine         = new DoubleVector(new double[]
            {
                cooDist[0].coordinate.GetNormPow() - cooDist[2].coordinate.GetNormPow() - cooDist[0].GetDistPow() + cooDist[2].GetDistPow(),
                cooDist[1].coordinate.GetNormPow() - cooDist[2].coordinate.GetNormPow() - cooDist[1].GetDistPow() + cooDist[2].GetDistPow()
            });

            vectorSecondAndThirdLine = vectorSecondAndThirdLine.Transform((p) => p / 2);

            DoubleVector coordinateVectorSecondAndThirdLine = NMathFunctions.Product(inversedMatrixSecondAndThirdLine,
                                                                                     vectorSecondAndThirdLine);

            coordinateSecondAndThirdLine.Xaxis = (int)coordinateVectorSecondAndThirdLine[0];
            coordinateSecondAndThirdLine.Yaxis = (int)coordinateVectorSecondAndThirdLine[1];

            int xaxis =
                (coordinateFirstAndSecondLine.Xaxis +
                 coordinateFirstAndThirdLine.Xaxis +
                 coordinateSecondAndThirdLine.Xaxis) / 3;
            int yaxis =
                (coordinateFirstAndSecondLine.Yaxis +
                 coordinateFirstAndThirdLine.Yaxis +
                 coordinateSecondAndThirdLine.Yaxis) / 3;

            Debug.WriteLine("Xaxis:" + xaxis);
            Debug.WriteLine("Yaxis:" + yaxis);

            return(new Coordinate()
            {
                Xaxis = xaxis,
                Yaxis = yaxis
            });
        }
Example #17
0
        private Coordinate Positioning_KnnProximity(List <AdjustedFingerprinting> fingerprintings)
        {
            int k = 3;
            /* run the knn classifier on the data */
            KnnClassifier classifier = new KnnClassifier();

            /* After fetching and processing the fingerprinting data, I am able to get the class count.
             * Basically, each of the reference point is a class to be classified to. */
            int numClasses   = IndoorPositioningClient.GetPoints(environment.EnvironmentId).Count;
            int gatewayCount = fingerprintings[0].RssiValueAndGateway.Count;

            /* get the Rssi values of the beacon in question from the server */
            RssiValue[] rssiValues = IndoorPositioningClient.GetRssi(gatewayCount);

            /* we will use also gateway count on the area as K constant */
            CoordinateAndDistance[] cooDist         = classifier.GetNearestNeighbors(rssiValues, fingerprintings, numClasses, k);
            Coordinate coordinateFirstAndSecondLine = new Coordinate();
            Coordinate coordinateFirstAndThirdLine  = new Coordinate();
            Coordinate coordinateSecondAndThirdLine = new Coordinate();

            /* Create a vector from the coordinates */
            /* Measure the first point of crossing the first and second line*/
            DoubleMatrix matrixFirstAndSecondLine = new DoubleMatrix(new double[, ]
            {
                {
                    cooDist[0].coordinate.Xaxis - cooDist[1].coordinate.Xaxis,
                    cooDist[0].coordinate.Yaxis - cooDist[1].coordinate.Yaxis
                },
                {
                    cooDist[0].coordinate.Xaxis - cooDist[2].coordinate.Xaxis,
                    cooDist[0].coordinate.Yaxis - cooDist[2].coordinate.Yaxis
                }
            });

            /* If the determinant value of the matrix is 0, it means this matrix cannot be inverted.
             * We can have the exact point values with one of the reference points. */
            if (NMathFunctions.Determinant(matrixFirstAndSecondLine) == 0)
            {
                return(classifier.Vote(cooDist, fingerprintings, numClasses, k));
            }

            //matrixFirstAndSecondLine = matrixFirstAndSecondLine.Transform((p) => p * 2);
            DoubleMatrix inversedMatrixFirstAndSecondLine = NMathFunctions.Inverse(matrixFirstAndSecondLine);
            DoubleVector vectorFirstAndSecondLine         = new DoubleVector(new double[]
            {
                cooDist[0].coordinate.GetNormPow() - cooDist[1].coordinate.GetNormPow() - cooDist[0].GetDistPow() + cooDist[1].GetDistPow(),
                cooDist[0].coordinate.GetNormPow() - cooDist[2].coordinate.GetNormPow() - cooDist[0].GetDistPow() + cooDist[2].GetDistPow()
            });

            vectorFirstAndSecondLine = vectorFirstAndSecondLine.Transform((p) => p / 2);

            DoubleVector coordinateVectorFirstAndSecondLine = NMathFunctions.Product(inversedMatrixFirstAndSecondLine,
                                                                                     vectorFirstAndSecondLine);

            coordinateFirstAndSecondLine.Xaxis = (int)coordinateVectorFirstAndSecondLine[0];
            coordinateFirstAndSecondLine.Yaxis = (int)coordinateVectorFirstAndSecondLine[1];

            /* Measure the first point of crossing the first and third line*/
            DoubleMatrix matrixFirstAndThirdLine = new DoubleMatrix(new double[, ]
            {
                {
                    cooDist[0].coordinate.Xaxis - cooDist[1].coordinate.Xaxis,
                    cooDist[0].coordinate.Yaxis - cooDist[1].coordinate.Yaxis
                },
                {
                    cooDist[1].coordinate.Xaxis - cooDist[2].coordinate.Xaxis,
                    cooDist[1].coordinate.Yaxis - cooDist[2].coordinate.Yaxis
                }
            });

            /* If the determinant value of the matrix is 0, it means this matrix cannot be inverted.
             * We can have the exact point values with one of the reference points. */
            if (NMathFunctions.Determinant(matrixFirstAndThirdLine) == 0)
            {
                return(classifier.Vote(cooDist, fingerprintings, numClasses, k));
            }

            //matrixFirstAndThirdLine = matrixFirstAndThirdLine.Transform((p) => p * 2);
            DoubleMatrix inversedMatrixFirstAndThirdLine = NMathFunctions.Inverse(matrixFirstAndThirdLine);
            DoubleVector vectorFirstAndThirdLine         = new DoubleVector(new double[]
            {
                cooDist[0].coordinate.GetNormPow() - cooDist[1].coordinate.GetNormPow() - cooDist[0].GetDistPow() + cooDist[1].GetDistPow(),
                cooDist[1].coordinate.GetNormPow() - cooDist[2].coordinate.GetNormPow() - cooDist[1].GetDistPow() + cooDist[2].GetDistPow()
            });

            vectorFirstAndThirdLine = vectorFirstAndThirdLine.Transform((p) => p / 2);

            DoubleVector coordinateVectorFirstAndThirdLine = NMathFunctions.Product(inversedMatrixFirstAndThirdLine,
                                                                                    vectorFirstAndThirdLine);

            coordinateFirstAndThirdLine.Xaxis = (int)coordinateVectorFirstAndThirdLine[0];
            coordinateFirstAndThirdLine.Yaxis = (int)coordinateVectorFirstAndThirdLine[1];

            /* Measure the first point of crossing the first and third line*/
            DoubleMatrix matrixSecondAndThirdLine = new DoubleMatrix(new double[, ]
            {
                {
                    cooDist[0].coordinate.Xaxis - cooDist[2].coordinate.Xaxis,
                    cooDist[0].coordinate.Yaxis - cooDist[2].coordinate.Yaxis
                },
                {
                    cooDist[1].coordinate.Xaxis - cooDist[2].coordinate.Xaxis,
                    cooDist[1].coordinate.Yaxis - cooDist[2].coordinate.Yaxis
                }
            });

            /* If the determinant value of the matrix is 0, it means this matrix cannot be inverted.
             * We can have the exact point values with one of the reference points. */
            if (NMathFunctions.Determinant(matrixSecondAndThirdLine) == 0)
            {
                return(classifier.Vote(cooDist, fingerprintings, numClasses, k));
            }

            //matrixSecondAndThirdLine = matrixSecondAndThirdLine.Transform((p) => p * 2);
            DoubleMatrix inversedMatrixSecondAndThirdLine = NMathFunctions.Inverse(matrixSecondAndThirdLine);
            DoubleVector vectorSecondAndThirdLine         = new DoubleVector(new double[]
            {
                cooDist[0].coordinate.GetNormPow() - cooDist[2].coordinate.GetNormPow() - cooDist[0].GetDistPow() + cooDist[2].GetDistPow(),
                cooDist[1].coordinate.GetNormPow() - cooDist[2].coordinate.GetNormPow() - cooDist[1].GetDistPow() + cooDist[2].GetDistPow()
            });

            vectorSecondAndThirdLine = vectorSecondAndThirdLine.Transform((p) => p / 2);

            DoubleVector coordinateVectorSecondAndThirdLine = NMathFunctions.Product(inversedMatrixSecondAndThirdLine,
                                                                                     vectorSecondAndThirdLine);

            coordinateSecondAndThirdLine.Xaxis = (int)coordinateVectorSecondAndThirdLine[0];
            coordinateSecondAndThirdLine.Yaxis = (int)coordinateVectorSecondAndThirdLine[1];

            //DoubleMatrix matrixFirstAndThirdLine = new DoubleMatrix(new double[,]
            //{
            //    {
            //        cooDist[0].coordinate.Xaxis - cooDist[1].coordinate.Xaxis,
            //        cooDist[0].coordinate.Yaxis - cooDist[1].coordinate.Yaxis
            //    },
            //    {
            //        cooDist[0].coordinate.Xaxis - cooDist[2].coordinate.Xaxis,
            //        cooDist[0].coordinate.Yaxis - cooDist[2].coordinate.Yaxis
            //    },
            //    {
            //        cooDist[1].coordinate.Xaxis - cooDist[2].coordinate.Xaxis,
            //        cooDist[1].coordinate.Yaxis - cooDist[2].coordinate.Yaxis
            //    }
            //});
            //DoubleMatrix inversedMatrix = NMathFunctions.Inverse(matrix);
            //DoubleVector vector = new DoubleVector(new double[]
            //{
            //    cooDist[0].coordinate.GetNormPow() - cooDist[1].coordinate.GetNormPow() - cooDist[0].GetDistPow() + cooDist[1].GetDistPow(),
            //    cooDist[0].coordinate.GetNormPow() - cooDist[2].coordinate.GetNormPow() - cooDist[0].GetDistPow() + cooDist[2].GetDistPow(),
            //    cooDist[1].coordinate.GetNormPow() - cooDist[2].coordinate.GetNormPow() - cooDist[1].GetDistPow() + cooDist[2].GetDistPow()
            //});
            //DoubleVector coordinateVector = NMathFunctions.Product(inversedMatrix, vector);
            //coordinate.Xaxis = (int)coordinateVector[0];
            //coordinate.Xaxis = (int)coordinateVector[1];

            //Matrix linesMatrix = new Matrix(
            //    cooDist[0].coordinate.Xaxis - cooDist[1].coordinate.Xaxis,
            //    cooDist[0].coordinate.Yaxis - cooDist[1].coordinate.Yaxis,
            //    cooDist[0].coordinate.Xaxis - cooDist[2].coordinate.Xaxis,
            //    cooDist[0].coordinate.Yaxis - cooDist[2].coordinate.Yaxis,
            //    cooDist[1].coordinate.Xaxis - cooDist[2].coordinate.Xaxis,
            //    cooDist[1].coordinate.Yaxis - cooDist[2].coordinate.Yaxis);

            ////Vector distances = new Vector(
            ////    coordinateAndDistances[0].coordinate.Xaxis - coordinateAndDistances[1].coordinate.Xaxis,);

            int xaxis =
                (coordinateFirstAndSecondLine.Xaxis +
                 coordinateFirstAndThirdLine.Xaxis +
                 coordinateSecondAndThirdLine.Xaxis) / 3;
            int yaxis =
                (coordinateFirstAndSecondLine.Yaxis +
                 coordinateFirstAndThirdLine.Yaxis +
                 coordinateSecondAndThirdLine.Yaxis) / 3;

            Debug.WriteLine("Xaxis:" + xaxis);
            Debug.WriteLine("Yaxis:" + yaxis);

            return(new Coordinate()
            {
                Xaxis = xaxis,
                Yaxis = yaxis
            });
        }