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


C# Vector2.Equals方法代码示例

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


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

示例1: VectorXEqualsVactorX

        public void VectorXEqualsVactorX()
        {
            var vectorX = new Vector2(1.0, 1.0);

            Assert.IsTrue(vectorX == vectorX);
            Assert.IsTrue(vectorX.Equals(vectorX));
            Assert.IsTrue(vectorX.Equals((object)vectorX));
        }
开发者ID:kridy,项目名称:3DMath,代码行数:8,代码来源:Vector2EqualityFixture.cs

示例2: Vector2_EqualsTestsCorrectly

        public void Vector2_EqualsTestsCorrectly()
        {
            var vector1 = new Vector2(123.4f, 567.8f);
            var vector2 = new Vector2(123.4f, 567.8f);
            var vector3 = new Vector2(567.8f, 123.4f);

            TheResultingValue(vector1.Equals(vector2)).ShouldBe(true);
            TheResultingValue(vector1.Equals(vector3)).ShouldBe(false);
        }
开发者ID:prshreshtha,项目名称:ultraviolet,代码行数:9,代码来源:Vector2Tests.cs

示例3: VectorXNotEqualsVectorY

        public void VectorXNotEqualsVectorY()
        {
            var vectorX = new Vector2(1.0, 1.0);
            var vectorY = new Vector2(2.0, 2.0);

            Assert.IsFalse(vectorX == vectorY);
            Assert.IsTrue(vectorX != vectorY);
            Assert.IsFalse(vectorX.Equals(vectorY));
            Assert.IsFalse(vectorX.Equals((object)vectorY));
        }
开发者ID:kridy,项目名称:3DMath,代码行数:10,代码来源:Vector2EqualityFixture.cs

示例4: VectorXEqualsVectorYEqualsVectorZTransitiveEquality

        public void VectorXEqualsVectorYEqualsVectorZTransitiveEquality()
        {
            var vectorX = new Vector2(1.0, 1.0);
            var vectorY = new Vector2(1.0, 1.0);
            var vectorZ = new Vector2(1.0, 1.0);

            Assert.IsTrue(vectorX.Equals(vectorY));
            Assert.IsTrue(vectorY.Equals(vectorZ));
            Assert.IsTrue(vectorX.Equals(vectorZ));

            Assert.IsTrue(vectorX.Equals((object)vectorY));
            Assert.IsTrue(vectorY.Equals((object)vectorZ));
            Assert.IsTrue(vectorX.Equals((object)vectorZ));
        }
开发者ID:kridy,项目名称:3DMath,代码行数:14,代码来源:Vector2EqualityFixture.cs

示例5: NaNEquality

		public void NaNEquality()
		{
			Vector2 nanVec = new Vector2(float.NaN, float.NaN);
			Assert.IsFalse(nanVec == nanVec);
			Assert.IsTrue(nanVec != nanVec);
			Assert.IsTrue(nanVec.Equals(nanVec));
		}
开发者ID:CodesInChaos,项目名称:Mono.GameMath,代码行数:7,代码来源:Vector2Tests.cs

示例6: Test_Equals

        public void Test_Equals()
        {
            var a = new Vector2 (1, 2.00001f);
            var b = new Vector2 (1, 2.00002f);

            Assert.IsTrue (a.Equals (b));   // 誤差を許容する比較
            Assert.IsFalse (a == b);        // 厳密な比較
            Assert.AreNotEqual (a.GetHashCode (), b.GetHashCode ()); // ハッシュは厳密な比較を基準
        }
开发者ID:weimingtom,项目名称:erica,代码行数:9,代码来源:TestVector2.cs

示例7: FindUV

        public UInt16 FindUV(Vector2 v)
        {
            UInt16 index = (UInt16)Geometry.UVs.FindIndex(delegate(Vector2 p) { return v.Equals(p); });
            if (index >= 0)
                return index;

            Geometry.UVs.Add(v);
            return (UInt16)(Geometry.UVs.Count - 1);
        }
开发者ID:JeffM2501,项目名称:CSC370,代码行数:9,代码来源:Mesh.cs

示例8: OnDraw

        private static void OnDraw(EventArgs args)
        {
            if (_notifications.Count != 0)
            {
                var lastNotifPos = new Vector2();
                var auxNotifications = new List<NotificationModel>();

                foreach (var notificationModel in _notifications)
                {
                    var diffTime = (notificationModel.StartTimer + notificationModel.AnimationTimer + notificationModel.ShowTimer) - Game.Time;

                    var animationEnd = notificationModel.StartTimer + notificationModel.AnimationTimer - Game.Time;

                    var diffPos = 0f;

                    if (animationEnd > 0)
                    {
                        diffPos = 200 * animationEnd;
                    }

                    if (diffTime > 0)
                    {
                        if (lastNotifPos.Equals(new Vector2()))
                        {
                            var pos = new Vector2(Drawing.Width - 220, y: Drawing.Height / 13.5f - diffPos);
                            MainBar.Draw(pos);
                            lastNotifPos = pos;
                            Text.TextValue = notificationModel.ShowText;
                            
                            var vector1 = new Vector2(Text.Bounding.Width, Text.Bounding.Height);
                            var vector2 = new Vector2(Resources.notification.Size.Width,
                                Resources.notification.Size.Height);

                            pos += (vector2 - vector1) / 2;

                            Text.Position = pos;
                            Text.Color = notificationModel.Color;
                            Text.Draw();
                        }
                        else
                        {
                            var pos = new Vector2(lastNotifPos.X, y: lastNotifPos.Y + 70);
                            MainBar.Draw(pos);
                            lastNotifPos = pos;
                            Text.TextValue = notificationModel.ShowText;

                            var vector1 = new Vector2(Text.Bounding.Width, Text.Bounding.Height);
                            var vector2 = new Vector2(Resources.notification.Size.Width,
                                Resources.notification.Size.Height);

                            pos += (vector2 - vector1) / 2;

                            Text.Position = pos;
                            Text.Color = notificationModel.Color;
                            Text.Draw();
                        }
                    }
                    else
                    {
                        auxNotifications.Add(notificationModel);
                    }
                }

                if (auxNotifications.Count > 0)
                {
                    _notifications = _notifications.Except(auxNotifications).ToList();
                }
            }
            else
            {
                Drawing.OnDraw -= OnDraw;
            }
        }
开发者ID:himrengod,项目名称:Elobuddy-1,代码行数:73,代码来源:Notification.cs

示例9: TestEquality

        // Test Operator: Equality //-----------------------------------------//

        /// <summary>
        /// Helper method for testing equality.
        /// </summary>
        void TestEquality (Vector2 a, Vector2 b, Boolean expected )
        {
            // This test asserts the following:
            //   (a == b) == expected
            //   (b == a) == expected
            //   (a != b) == !expected
            //   (b != a) == !expected

            Boolean result_1a = (a == b);
            Boolean result_1b = (a.Equals(b));
            Boolean result_1c = (a.Equals((Object)b));

            Boolean result_2a = (b == a);
            Boolean result_2b = (b.Equals(a));
            Boolean result_2c = (b.Equals((Object)a));

            Boolean result_3a = (a != b);
            Boolean result_4a = (b != a);

            Assert.That(result_1a, Is.EqualTo(expected));
            Assert.That(result_1b, Is.EqualTo(expected));
            Assert.That(result_1c, Is.EqualTo(expected));
            Assert.That(result_2a, Is.EqualTo(expected));
            Assert.That(result_2b, Is.EqualTo(expected));
            Assert.That(result_2c, Is.EqualTo(expected));
            Assert.That(result_3a, Is.EqualTo(!expected));
            Assert.That(result_4a, Is.EqualTo(!expected));
        }
开发者ID:sungiant,项目名称:abacus,代码行数:33,代码来源:Abacus.Double.Tests.cs

示例10: HandlePlayerUpdate

        private static bool HandlePlayerUpdate(GetDataHandlerArgs args)
        {
            var plr = args.Data.ReadInt8();
            var control = args.Data.ReadInt8();
            var item = args.Data.ReadInt8();
            var pos = new Vector2(args.Data.ReadSingle(), args.Data.ReadSingle());
            var vel = new Vector2(args.Data.ReadSingle(), args.Data.ReadSingle());

            if (item < 0 || item >= args.TPlayer.inventory.Length)
            {
                return true;
            }

            if (!pos.Equals(args.Player.LastNetPosition))
            {
                float distance = Vector2.Distance(new Vector2(pos.X / 16f, pos.Y / 16f), new Vector2(args.Player.LastNetPosition.X / 16f, args.Player.LastNetPosition.Y / 16f));
                if (TShock.CheckIgnores(args.Player) && distance > TShock.Config.MaxRangeForDisabled)
                {
                    if(args.Player.IgnoreActionsForCheating != "none")
                    {
                        args.Player.SendMessage("Disabled for cheating: " + args.Player.IgnoreActionsForCheating, Color.Red);
                    }
                    else if (args.Player.IgnoreActionsForDisabledArmor != "none")
                    {
                        args.Player.SendMessage("Disabled for banned armor: " + args.Player.IgnoreActionsForDisabledArmor, Color.Red);
                    }
                    else if (args.Player.IgnoreActionsForInventory != "none")
                    {
                        args.Player.SendMessage("Disabled for Server Side Inventory: " + args.Player.IgnoreActionsForInventory, Color.Red);
                    }
                    else if (TShock.Config.RequireLogin && !args.Player.IsLoggedIn)
                    {
                        args.Player.SendMessage("Please /register or /login to play!", Color.Red);
                    }
                    else if (args.Player.IgnoreActionsForClearingTrashCan)
                    {
                        args.Player.SendMessage("You need to rejoin to ensure your trash can is cleared!", Color.Red);
                    }
                    else if (args.Player.IgnoreActionsForPvP)
                    {
                        args.Player.SendMessage("PvP is forced! Enable PvP else you can't move or do anything!", Color.Red);
                    }
                    int lastTileX = (int)(args.Player.LastNetPosition.X / 16f);
                    int lastTileY = (int)(args.Player.LastNetPosition.Y / 16f);
                    if (!args.Player.Teleport(lastTileX, lastTileY + 3))
                    {
                        args.Player.Spawn();
                    }
                    return true;
                }

                if (args.Player.Dead)
                {
                    return true;
                }

                if (!args.Player.Group.HasPermission(Permissions.ignorenoclipdetection) && Collision.SolidCollision(pos, args.TPlayer.width, args.TPlayer.height))
                {
                    int lastTileX = (int)(args.Player.LastNetPosition.X / 16f);
                    int lastTileY = (int)(args.Player.LastNetPosition.Y / 16f);
                    if (!args.Player.Teleport(lastTileX, lastTileY + 3))
                    {
                        args.Player.SendMessage("You got stuck in a solid object, Sent to spawn point.");
                        args.Player.Spawn();
                    }
                    return true;
                }
            }
            args.Player.LastNetPosition = pos;

            if ((control & 32) == 32)
            {
                if (!args.Player.Group.HasPermission(Permissions.usebanneditem) && TShock.Itembans.ItemIsBanned(args.TPlayer.inventory[item].name, args.Player))
                {
                    control -= 32;
                    args.Player.LastThreat = DateTime.UtcNow;
                    args.Player.SendMessage(string.Format("You cannot use {0} on this server. Your actions are being ignored.", args.TPlayer.inventory[item].name), Color.Red);
                }
            }

            args.TPlayer.selectedItem = item;
            args.TPlayer.position = pos;
            args.TPlayer.velocity = vel;
            args.TPlayer.oldVelocity = args.TPlayer.velocity;
            args.TPlayer.fallStart = (int)(pos.Y / 16f);
            args.TPlayer.controlUp = false;
            args.TPlayer.controlDown = false;
            args.TPlayer.controlLeft = false;
            args.TPlayer.controlRight = false;
            args.TPlayer.controlJump = false;
            args.TPlayer.controlUseItem = false;
            args.TPlayer.direction = -1;
            if ((control & 1) == 1)
            {
                args.TPlayer.controlUp = true;
            }
            if ((control & 2) == 2)
            {
                args.TPlayer.controlDown = true;
            }
//.........这里部分代码省略.........
开发者ID:pfchrono,项目名称:Toaria,代码行数:101,代码来源:GetDataHandlers.cs

示例11: EqualsTest1

        public void EqualsTest1()
        {
            Vector2 target = new Vector2(5f, 8.5f);
            object value = new Vector2(6f, 15.1f);
            bool expected = false;
            bool actual;
            actual = target.Equals(value);
            Utilities.AreEqual(expected, actual);

            target = new Vector2(7f, 3f);
            value = new Vector2(7f, 3f);
            expected = true;
            actual = target.Equals(value);
            Utilities.AreEqual(expected, actual);
        }
开发者ID:samitc,项目名称:slimmath,代码行数:15,代码来源:Vector2Test.cs

示例12: VectorXEqualsNull

 public void VectorXEqualsNull()
 {
     var vectorX = new Vector2(1.0, 1.0);
     Assert.IsFalse(vectorX.Equals(null));
 }
开发者ID:kridy,项目名称:3DMath,代码行数:5,代码来源:Vector2EqualityFixture.cs

示例13: 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">Minimum distance from which approximate curved segments of the polyline.</param>
        /// <returns>A list of vertexes expressed in object coordinate system.</returns>
        public IList<Vector2> PoligonalVertexes(int bulgePrecision, double weldThreshold, double bulgeThreshold)
        {
            List<Vector2> ocsVertexes = new List<Vector2>();

            int index = 0;

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

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

                if (!p1.Equals(p2, weldThreshold))
                {
                    if (MathHelper.IsZero(bulge) || bulgePrecision == 0)
                    {
                        ocsVertexes.Add(p1);
                    }
                    else
                    {
                        double c = Vector2.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 = Vector2.Angle(p1, p2) + Math.Sign(bulge) * gamma;
                            Vector2 center = new Vector2(p1.X + r * Math.Cos(phi), p1.Y + r * Math.Sin(phi));
                            Vector2 a1 = p1 - center;
                            double angle = Math.Sign(bulge) * theta / (bulgePrecision + 1);
                            ocsVertexes.Add(p1);
                            for (int i = 1; i <= bulgePrecision; i++)
                            {
                                Vector2 curvePoint = new Vector2();
                                Vector2 prevCurvePoint = new Vector2(this.vertexes[this.vertexes.Count - 1].Position.X, this.vertexes[this.vertexes.Count - 1].Position.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:DaishiNakase,项目名称:WaveguideDesigner,代码行数:74,代码来源:LwPolyline.cs

示例14: CheckOne

 private static void CheckOne(LensDistortionMapping correction, Vector2 distorted)
 {
     Vector2 corrected = correction.GetCorrected(distorted);
     Vector2 redistorted = correction.GetDistorted(corrected);
     Assert.IsTrue(distorted.Equals(redistorted, .05));
 }
开发者ID:glocklueng,项目名称:agg-sharp,代码行数:6,代码来源:UnitTests.cs

示例15: SetEllipseParameters

        private void SetEllipseParameters(Ellipse ellipse, double[] param)
        {
            double a = ellipse.MajorAxis*0.5;
            double b = ellipse.MinorAxis*0.5;

            Vector2 startPoint = new Vector2(a * Math.Cos(param[0]), b * Math.Sin(param[0]));
            Vector2 endPoint = new Vector2(a * Math.Cos(param[1]), b * Math.Sin(param[1]));

            // trigonometry functions are very prone to round off errors
            if (startPoint.Equals(endPoint))
            {
                ellipse.StartAngle = 0.0;
                ellipse.EndAngle = 360.0;
            }
            else
            {
                ellipse.StartAngle = Vector2.Angle(startPoint) * MathHelper.RadToDeg;
                ellipse.EndAngle = Vector2.Angle(endPoint) * MathHelper.RadToDeg;
            }
        }
开发者ID:3DInstruments,项目名称:Kaliber3D,代码行数:20,代码来源:DxfReader.cs


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