Canguro.Model.Section.FrameSection.CalcProps C# (CSharp) Метод

CalcProps() защищенный Метод

Calculates Area, I33 and I22
protected CalcProps ( ) : void
Результат void
        protected void CalcProps()
        {
            if (contour != null && contour.Length > 0 && contour[0] != null)
            {
                float r1 = 0;
                float r2 = 0;
                float x1 = 0;
                float y1 = 0;
                float x2 = 0;
                float y2 = 0;
                area = 0;

                int count = contour[0].Length;
                for (int i = 0; i < count; i++)
                {
                    x1 = contour[0][i].X;
                    y1 = contour[0][i].Y;
                    x2 = contour[0][(i + 1) % count].X;
                    y2 = contour[0][(i + 1) % count].Y;
                    // Area
                    float s = (x1 * y2 - x2 * y1) / 2f;
                    area += s;
                    // Centroid
                    float z1 = (x1 + x2) / 3f;
                    float z2 = (y1 + y2) / 3f;
                    // Inertia Moments
                    r1 = r1 + s * (y1 * y1 + y2 * y2 + y1 * y2) / 6f;
                    r2 = r2 + s * (x1 * x1 + x2 * x2 + x1 * x2) / 6f;
                }
                area = Math.Abs(area);
                i22 = Math.Abs(r1);
                i33 = Math.Abs(r2);
            }
        }