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


C# C2DPoint.Multiply方法代码示例

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


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

示例1: GetCentroid

        /// <summary>
        /// Returns the centroid.
        /// </summary>
        public C2DPoint GetCentroid()
        {
            // Find the centroid and area of the straight line polygon.
            C2DPoint Centroid = new C2DPoint(0, 0);
             //   C2DPoint pti = new C2DPoint();
             //   C2DPoint ptii;
            double dArea = 0;

            for (int i = 0; i < Lines.Count; i++)
            {
                C2DPoint pti = Lines[i].GetPointFrom();
                C2DPoint ptii = Lines[i].GetPointTo();

                Centroid.x += (pti.x + ptii.x) * (pti.x * ptii.y - ptii.x * pti.y);
                Centroid.y += (pti.y + ptii.y) * (pti.x * ptii.y - ptii.x * pti.y);

                dArea += pti.x * ptii.y - ptii.x * pti.y;
            }
            dArea = dArea / 2.0;

            Centroid.x = Centroid.x / (6.0 * dArea);
            Centroid.y = Centroid.y / (6.0 * dArea);

            List<double> dSegAreas = new List<double>();
            double dTotalArea = dArea;
            List<C2DPoint> SegCentroids = new List<C2DPoint>();

            for (int i = 0; i < Lines.Count; i++)
            {
                if (Lines[i] is C2DArc)
                {
                    C2DSegment Seg = new C2DSegment( Lines[i] as C2DArc );
                    double dSegArea = Seg.GetAreaSigned();
                    dTotalArea += dSegArea;
                    dSegAreas.Add( dSegArea );
                    SegCentroids.Add( Seg.GetCentroid() );
                }
            }

            Centroid.Multiply( dArea);

            for (int i = 0; i < dSegAreas.Count; i++)
            {
                Centroid.x += SegCentroids[i].x * dSegAreas[i];
                Centroid.y += SegCentroids[i].y * dSegAreas[i];
            }

            Centroid.Multiply( 1/ dTotalArea);
            return Centroid;
        }
开发者ID:nvankaam,项目名称:DelaunayTriangulation,代码行数:53,代码来源:C2DPolyArc.cs

示例2: GetCentroid

        /// <summary>
        /// Returns the centroid.
        /// </summary>
        public C2DPoint GetCentroid()
        {
            // Find the area first. Do it explicitly as we may need bits of the calc later.
            double dSegAng = Arc.GetSegmentAngle();
            bool bBig = Arc.ArcOnRight == Arc.CentreOnRight;

            double dRadius = Arc.Radius;
            double dRadiusSquare = dRadius * dRadius;
            double dCircleArea = dRadiusSquare * Constants.conPI;
            double dArea = dRadiusSquare * ( (dSegAng - Math.Sin(dSegAng)) / 2);

            // Find the maximum length of the small segment along the direction of the line.
            double dLength = Arc.Line.GetLength();
            // Now find the average height of the segment over that line
            double dHeight = dArea / dLength;

            // Find the centre point on the line and the centre of the circle
            C2DPoint ptLineCen = new C2DPoint(Arc.Line.GetMidPoint());
            C2DPoint ptCircleCen = new C2DPoint(Arc.GetCircleCentre());

            // Set up a line from the mid point on the line to the circle centre
            // then set the length of it to the average height divided by 2. The end
            // point of the line is then the centroid. If we are using the small bit,
            // The line needs to be reversed.
            C2DLine Line = new C2DLine( ptLineCen, ptCircleCen);

            Line.vector.Reverse();

            Line.vector.SetLength(  dHeight / 2 );

            if (bBig)
            {
                C2DPoint ptSmallCen = new C2DPoint(Line.GetPointTo());
                // Return the weighted average of the 2 centroids.

                ptCircleCen.Multiply(dCircleArea);
                ptSmallCen.Multiply(dArea);
                C2DPoint pRes = ptCircleCen - ptSmallCen;
                pRes.Multiply(1.0 / (dCircleArea - dArea));
                return pRes;
               //     return ( new C2DPoint(ptCircleCen * dCircleArea - ptSmallCen * dArea) ) / ( dCircleArea - dArea);
            }
            else
                return Line.GetPointTo();
        }
开发者ID:nvankaam,项目名称:DelaunayTriangulation,代码行数:48,代码来源:C2DSegment.cs


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