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


C# Vector2d.Equals方法代码示例

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


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

示例1: PoligonalVertexes

        /// <summary>
        /// Converts the circle in a list of vertexes.
        /// </summary>
        /// <param name="precision">Number of vertexes generated.</param>
        /// <param name="weldThreshold">Tolerance to consider if two new generated vertexes are equal.</param>
        /// <returns>A list vertexes that represents the circle expresed in object coordinate system.</returns>
        public List<Vector2d> PoligonalVertexes(int precision, double weldThreshold)
        {
            if (precision < 3)
                throw new ArgumentOutOfRangeException("precision", precision, "The circle precision must be greater or equal to three");

            List<Vector2d> ocsVertexes = new List<Vector2d>();

            if (2*this.radius >= weldThreshold)
            {
                double angulo = (MathHelper.TwoPI / precision);
                Vector2d prevPoint;
                Vector2d firstPoint;

                double sine = (this.radius * Math.Sin(MathHelper.HalfPI * 0.5));
                double cosine = (this.radius * Math.Cos(MathHelper.HalfPI * 0.5));
                firstPoint = new Vector2d(cosine + this.center.X, sine + this.center.Y);
                ocsVertexes.Add(firstPoint);
                prevPoint = firstPoint;

                for (int i = 1; i < precision; i++)
                {
                    sine = (this.radius*Math.Sin(MathHelper.HalfPI + angulo*i));
                    cosine = (this.radius*Math.Cos(MathHelper.HalfPI + angulo*i));
                    Vector2d point = new Vector2d(cosine + this.center.X, sine + this.center.Y);

                    if (!point.Equals(prevPoint, weldThreshold) &&
                        !point.Equals(firstPoint, weldThreshold))
                    {
                        ocsVertexes.Add(point);
                        prevPoint = point;
                    }
                }
            }

            return ocsVertexes;
        }
开发者ID:steve-stanton,项目名称:backsight,代码行数:42,代码来源:Circle.cs

示例2: PoligonalVertexes

        /// <summary>
        /// Converts the arc in a list of vertexes.
        /// </summary>
        /// <param name="precision">Number of vertexes generated.</param>
        /// <param name="weldThreshold">Tolerance to consider if two new generated vertexes are equal.</param>
        /// <returns>A list vertexes that represents the arc expresed in object coordinate system.</returns>
        public List<Vector2d> PoligonalVertexes(int precision, double weldThreshold)
        {
            if (precision < 2)
                throw new ArgumentOutOfRangeException("precision", precision, "The arc precision must be greater or equal to two");

            List<Vector2d> ocsVertexes = new List<Vector2d>();
            double start = this.startAngle * MathHelper.DegToRad;
            double end = this.endAngle * MathHelper.DegToRad;

            if (2*this.radius >= weldThreshold)
            {
                double angulo = (end - start) / precision;
                Vector2d prevPoint;
                Vector2d firstPoint;

                double sine = this.radius * Math.Sin(start);
                double cosine = this.radius * Math.Cos(start);
                firstPoint = new Vector2d(cosine + this.center.X, sine + this.center.Y);
                ocsVertexes.Add(firstPoint);
                prevPoint = firstPoint;

                for (int i = 1; i <= precision; i++)
                {
                    sine = this.radius*Math.Sin(start + angulo*i);
                    cosine = this.radius*Math.Cos(start + angulo*i);
                    Vector2d point = new Vector2d(cosine + this.center.X, sine + this.center.Y);

                    if (!point.Equals(prevPoint, weldThreshold) && !point.Equals(firstPoint, weldThreshold))
                    {
                        ocsVertexes.Add(point);
                        prevPoint = point;
                    }
                }
            }

            return ocsVertexes;
        }
开发者ID:steve-stanton,项目名称:backsight,代码行数:43,代码来源:Arc.cs

示例3: PoligonalVertexes

        /// <summary>
        /// Obtains a list of vertexes that represent the polyline approximating the curve segments as necessary.
        /// </summary>
        /// <param name="bulgePrecision">Curve segments precision (a value of zero means that no approximation will be made).</param>
        /// <param name="weldThreshold">Tolerance to consider if two new generated vertexes are equal.</param>
        /// <param name="bulgeThreshold">Minimun distance from which approximate curved segments of the polyline.</param>
        /// <returns>The return vertexes are expresed in object coordinate system.</returns>
        public List<Vector2d> PoligonalVertexes(int bulgePrecision, double weldThreshold, double bulgeThreshold)
        {
            List<Vector2d> ocsVertexes = new List<Vector2d>();

            int index = 0;

            foreach (LightWeightPolylineVertex vertex in this.Vertexes)
            {
                double bulge = vertex.Bulge;
                Vector2d p1;
                Vector2d p2;

                if (index == this.Vertexes.Count - 1)
                {
                    p1 = new Vector2d(vertex.Location.X, vertex.Location.Y);
                    p2 = new Vector2d(this.vertexes[0].Location.X, this.vertexes[0].Location.Y);
                }
                else
                {
                    p1 = new Vector2d(vertex.Location.X, vertex.Location.Y);
                    p2 = new Vector2d(this.vertexes[index + 1].Location.X, this.vertexes[index + 1].Location.Y);
                }

                if (!p1.Equals(p2, weldThreshold))
                {
                    if (bulge == 0 || bulgePrecision == 0)
                    {
                        ocsVertexes.Add(p1);
                    }
                    else
                    {
                        double c = Vector2d.Distance(p1, p2);
                        if (c >= bulgeThreshold)
                        {
                            double s = (c / 2) * Math.Abs(bulge);
                            double r = ((c / 2) * (c / 2) + s * s) / (2 * s);
                            double theta = 4 * Math.Atan(Math.Abs(bulge));
                            double gamma = (Math.PI - theta) / 2;
                            double phi;

                            if (bulge > 0)
                            {
                                phi = Vector2d.AngleBetween(Vector2d.UnitX, p2 - p1) + gamma;
                            }
                            else
                            {
                                phi = Vector2d.AngleBetween(Vector2d.UnitX, p2 - p1) - gamma;
                            }

                            Vector2d center = new Vector2d(p1.X + r*Math.Cos(phi), p1.Y + r*Math.Sin(phi));
                            Vector2d a1 = p1 - center;
                            double angle = 4 * (Math.Atan(bulge)) / (bulgePrecision + 1);

                            ocsVertexes.Add(p1);
                            for (int i = 1; i <= bulgePrecision; i++)
                            {
                                Vector2d curvePoint = new Vector2d();
                                Vector2d prevCurvePoint = new Vector2d(this.vertexes[this.vertexes.Count - 1].Location.X, this.vertexes[this.vertexes.Count - 1].Location.Y);
                                curvePoint.X = center.X + (Math.Cos(i*angle)*a1.X - Math.Sin(i*angle)*a1.Y);
                                curvePoint.Y = center.Y + (Math.Sin(i*angle)*a1.X + Math.Cos(i*angle)*a1.Y);

                                if (!curvePoint.Equals(prevCurvePoint, weldThreshold) &&
                                    !curvePoint.Equals(p2, weldThreshold))
                                {
                                    ocsVertexes.Add(curvePoint);
                                }
                            }
                        }
                        else
                        {
                            ocsVertexes.Add(p1);
                        }
                    }
                }
                index++;
            }

            return ocsVertexes;
        }
开发者ID:steve-stanton,项目名称:backsight,代码行数:86,代码来源:LightWeightPolyline.cs


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