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


C# Vector2f.Equals方法代码示例

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


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

示例1: 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<Vector2f> PoligonalVertexes(int bulgePrecision, float weldThreshold, float bulgeThreshold)
        {
            List<Vector2f> ocsVertexes = new List<Vector2f>();

            int index = 0;

            foreach (PolylineVertex vertex in this.Vertexes)
            {
                float bulge = vertex.Bulge;
                Vector2f p1;
                Vector2f p2;

                if (index == this.Vertexes.Count - 1)
                {
                    p1 = new Vector2f(vertex.Location.X, vertex.Location.Y);
                    p2 = new Vector2f(this.vertexes[0].Location.X, this.vertexes[0].Location.Y);
                }
                else
                {
                    p1 = new Vector2f(vertex.Location.X, vertex.Location.Y);
                    p2 = new Vector2f(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
                    {
                        float c = Vector2f.Distance(p1, p2);
                        if (c >= bulgeThreshold)
                        {
                            float s = (c/2)*Math.Abs(bulge);
                            float r = ((c/2)*(c/2) + s*s)/(2*s);
                            float theta = (float) (4*Math.Atan(Math.Abs(bulge)));
                            float gamma = (float) ((Math.PI - theta)/2);
                            float phi;

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

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

                            ocsVertexes.Add(p1);
                            for (int i = 1; i <= bulgePrecision; i++)
                            {
                                Vector2f curvePoint = new Vector2f();
                                Vector2f prevCurvePoint = new Vector2f(this.vertexes[this.vertexes.Count - 1].Location.X, this.vertexes[this.vertexes.Count - 1].Location.Y);
                                curvePoint.X = center.X + (float) (Math.Cos(i*angle)*a1.X - Math.Sin(i*angle)*a1.Y);
                                curvePoint.Y = center.Y + (float) (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:lomatus,项目名称:SharpDxf,代码行数:86,代码来源:Polyline.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<Vector2f> PoligonalVertexes(int precision, float weldThreshold)
        {
            if (precision < 2)
                throw new ArgumentOutOfRangeException("precision", precision, "The arc precision must be greater or equal to two");

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

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

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

                for (int i = 1; i <= precision; i++)
                {
                    sine = (float) (this.radius*Math.Sin(start + angulo*i));
                    cosine = (float) (this.radius*Math.Cos(start + angulo*i));
                    Vector2f point = new Vector2f(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:lomatus,项目名称:SharpDxf,代码行数:43,代码来源:Arc.cs

示例3: 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<Vector2f> PoligonalVertexes(int precision, float weldThreshold)
        {
            if (precision < 3)
                throw new ArgumentOutOfRangeException("precision", precision, "The circle precision must be greater or equal to three");

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

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

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

                for (int i = 1; i < precision; i++)
                {
                    sine = (float) (this.radius*Math.Sin(MathHelper.HalfPI + angulo*i));
                    cosine = (float) (this.radius*Math.Cos(MathHelper.HalfPI + angulo*i));
                    Vector2f point = new Vector2f(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:lomatus,项目名称:SharpDxf,代码行数:42,代码来源:Circle.cs


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