Exemplo n.º 1
0
        public double DistanceBetweenTwoPoints(VerticesOutput P1, VerticesOutput P2)
        {
            double dist = 0.0;

            try
            {
                dist = Math.Sqrt(Math.Pow((P2.x - P1.x), 2) +
                                 Math.Pow((P2.y - P1.y), 2) +
                                 Math.Pow((P2.z - P1.z), 2)
                                 );
            }
            catch (Exception ex)
            {
                //The expection info goes here
                string Message = ex.ToString() + "\n\n\n\n ERROR 3080 : Problems finding distance between points from Vertices Output ";
                string Caption = "Styling and Functional Pattern Design";

                // log.Info(" ERROR 3080 : Problems finding distance between points from Vertices Output ");

                MessageBoxButtons Buttons = MessageBoxButtons.RetryCancel;

                DialogResult Result = MessageBox.Show(
                    Message,
                    Caption,
                    Buttons,
                    MessageBoxIcon.Error);
            }

            return(dist);
        }
Exemplo n.º 2
0
        public int FindClosestPoint(VerticesOutput P)
        {
            int theClosestIndexIs = 0;

            try
            {
                ReadFileDataToList("meshd.srf");

                VerticesOutput theClosestPointIs = new VerticesOutput();

                double closestDistance = DistanceBetweenTwoPoints(P, VertexLocation[0]);


                double d = 0;

                for (int i = 0; i < VertexLocation.Count; i++)
                {
                    d = DistanceBetweenTwoPoints(P, VertexLocation[i]);

                    if (d < closestDistance)
                    {
                        closestDistance   = d;
                        theClosestIndexIs = i;
                    }
                }

                theClosestPointIs = VertexLocation[theClosestIndexIs];
            }
            catch (Exception ex)
            {
                //The expection info goes here
                string Message = ex.ToString() + "\n\n\n\n ERROR 3070 : Problems finding closest point ";
                string Caption = "Styling and Functional Pattern Design";

                // log.Info(" ERROR 3070 : Problems finding closest point ");

                MessageBoxButtons Buttons = MessageBoxButtons.RetryCancel;

                DialogResult Result = MessageBox.Show(
                    Message,
                    Caption,
                    Buttons,
                    MessageBoxIcon.Error);
            }

            return(theClosestIndexIs);
        }