当前位置: 首页>>代码示例>>C#>>正文


C# Contour.FindIndex方法代码示例

本文整理汇总了C#中Contour.FindIndex方法的典型用法代码示例。如果您正苦于以下问题:C# Contour.FindIndex方法的具体用法?C# Contour.FindIndex怎么用?C# Contour.FindIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Contour的用法示例。


在下文中一共展示了Contour.FindIndex方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MakeSystem

        //sets in matrix and vector the system, that must be solved by Cholesky
        //matrix and vector must be created and initialized 0 before this executing this method.
        public static void MakeSystem(ref List<Triangle> triangles, ref Contour contour, ref double[,] matrix, ref double[] vector)
        {
            double[,] K = new double[3, 3];
            double[] F = new double[3];

            double denominator_K; //4 * square of triangle
            double koefficient_line_segment; //length of line segment, devided on something
            int points_index_difference; //the difference of 2 points indexes: used to check are 2 point neighbors on the contour

            int last_point_index_in_contour = 0;
            foreach (Point point in contour)
                if (point.Index > last_point_index_in_contour)
                    last_point_index_in_contour = point.Index;

            foreach (Triangle triangle in triangles)
            {
                //-------------------make matrix K-------------------------------------------------------------

                K[0, 0] = 0.0; K[0, 1] = 0.0; K[0, 2] = 0.0;
                K[1, 0] = 0.0; K[1, 1] = 0.0; K[1, 2] = 0.0;
                K[2, 0] = 0.0; K[2, 1] = 0.0; K[2, 2] = 0.0;

                denominator_K = 4.0 * triangle.Square();

                K[0, 0] = ((triangle.J.Y - triangle.K.Y) * (triangle.J.Y - triangle.K.Y) +
                           (triangle.K.X - triangle.J.X) * (triangle.K.X - triangle.J.X)) / denominator_K;

                K[1, 1] = ((triangle.K.Y - triangle.I.Y) * (triangle.K.Y - triangle.I.Y) +
                           (triangle.I.X - triangle.K.X) * (triangle.I.X - triangle.K.X)) / denominator_K;

                K[2, 2] = ((triangle.I.Y - triangle.J.Y) * (triangle.I.Y - triangle.J.Y) +
                           (triangle.J.X - triangle.I.X) * (triangle.J.X - triangle.I.X)) / denominator_K;

                K[0, 1] = ((triangle.J.Y - triangle.K.Y) * (triangle.K.Y - triangle.I.Y) +
                           (triangle.K.X - triangle.J.X) * (triangle.I.X - triangle.K.X)) / denominator_K;

                K[0, 2] = ((triangle.J.Y - triangle.K.Y) * (triangle.I.Y - triangle.J.Y) +
                           (triangle.K.X - triangle.J.X) * (triangle.J.X - triangle.I.X)) / denominator_K;

                K[1, 2] = ((triangle.K.Y - triangle.I.Y) * (triangle.I.Y - triangle.J.Y) +
                           (triangle.I.X - triangle.K.X) * (triangle.J.X - triangle.I.X)) / denominator_K;

                K[1, 0] = K[0, 1];

                K[2, 0] = K[0, 2];

                K[2, 1] = K[1, 2];

                //--------------------------------------------------------------------------------------------------

                //------------------------------make matrix K_with_wave and vektor F---------------------------------

                F[0] = 0.0;
                F[1] = 0.0;
                F[2] = 0.0;

                if (contour.Contains(triangle.I))
                {
                    if (contour.Contains(triangle.J)) //if IJ
                    {
                        points_index_difference = contour.FindIndex( p => p.Index == triangle.I.Index)
                            - contour.FindIndex( p => p.Index == triangle.J.Index);
                        if ((points_index_difference == 1) || (points_index_difference == -1)
                            || (points_index_difference == contour.Count - 1))
                        {// if I and J are neighbors
                            koefficient_line_segment = triangle.IJ.Length / 3.0;

                            K[0, 0] += koefficient_line_segment;  // (length of IJ) / 3
                            K[1, 1] += koefficient_line_segment;  // (length of IJ) / 3

                            koefficient_line_segment = triangle.IJ.Length / 6.0;

                            K[0, 1] += koefficient_line_segment;  // (length of IJ) / 6
                            K[1, 0] += koefficient_line_segment;  // (length of IJ) / 6

                            koefficient_line_segment = (triangle.I.T + triangle.J.T) * triangle.IJ.Length / 4.0;
                            double f0 = FindKoefF(triangle.I, triangle.I, triangle.J, triangle);
                            double f1 = FindKoefF(triangle.J, triangle.I, triangle.J, triangle);
                            F[0] += f0;
                            F[1] += f1;
                        }
                    }

                    if (contour.Contains(triangle.K)) //if KI
                    {
                        points_index_difference = contour.FindIndex(p => p.Index == triangle.I.Index)
                            - contour.FindIndex(p => p.Index == triangle.K.Index);
                        if ((points_index_difference == 1) || (points_index_difference == -1)
                            || (points_index_difference == contour.Count - 1))
                        {// if I and K are neighbors
                            koefficient_line_segment = triangle.KI.Length / 3.0;

                            K[0, 0] += koefficient_line_segment;  //(length of KI) / 3
                            K[2, 2] += koefficient_line_segment;  //(length of KI) / 3

                            koefficient_line_segment = triangle.KI.Length / 6.0;

                            K[0, 2] += koefficient_line_segment;  //(length of KI) / 6
//.........这里部分代码省略.........
开发者ID:StanislavUshakov,项目名称:NumericalMethods,代码行数:101,代码来源:SystemMaker.cs


注:本文中的Contour.FindIndex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。