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


C# Vector3.Equals方法代码示例

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


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

示例1: Vector3_EqualsTestsCorrectly

        public void Vector3_EqualsTestsCorrectly()
        {
            var vector1 = new Vector3(123.4f, 567.8f, 901.2f);
            var vector2 = new Vector3(123.4f, 567.8f, 901.2f);
            var vector3 = new Vector3(901.2f, 567.8f, 123.4f);

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

示例2: NaNEquality

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

示例3: FilterTargets

 public static IEnumerable<Targets.Item> FilterTargets(IEnumerable<Targets.Item> targets,
     Vector3 from,
     float range)
 {
     var finalTargets = targets.ToList();
     var rangeDelay = _mainMenu.Item(_mainMenu.Name + ".range").GetValue<Slider>().Value;
     var fowDelay = _mainMenu.Item(_mainMenu.Name + ".fow").GetValue<Slider>().Value;
     if (rangeDelay > 0 && range > 0)
     {
         if (_lastRange > 0 && Game.Time - _lastRangeChange <= rangeDelay / 1000f)
         {
             finalTargets =
                 finalTargets.Where(
                     t =>
                         t.Hero.Distance(
                             from.Equals(default(Vector3)) ? ObjectManager.Player.ServerPosition : from) <=
                         _lastRange).ToList();
         }
         else if (Math.Abs(_lastRange - range) > 1)
         {
             _lastRange = range;
             _lastRangeChange = Game.Time;
         }
     }
     if (fowDelay > 0)
     {
         finalTargets =
             finalTargets.Where(item => Game.Time - item.LastVisibleChange > fowDelay / 1000f).ToList();
     }
     return finalTargets;
 }
开发者ID:understoodz,项目名称:LeagueSharp-Dev,代码行数:31,代码来源:Humanizer.cs

示例4: IsFacing

 public static bool IsFacing(this Obj_AI_Base source, Vector3 position, float angle = 90)
 {
     if (source == null || position.Equals(Vector3.Zero))
     {
         return false;
     }
     return source.Direction.To2D().Perpendicular().AngleBetween((position - source.Position).To2D()) < angle;
 }
开发者ID:zombiesing,项目名称:LeagueSharp-Standalones,代码行数:8,代码来源:Utils.cs

示例5: Test_Equals

        public void Test_Equals()
        {
            var a = new Vector3 (1, 2, 3.00001f);
            var b = new Vector3 (1, 2, 3.00002f);

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

示例6: ScalarDivision

        public void ScalarDivision()
        {
            Vector3 ScalarMultiplicationArgument = new Vector3(5.0f, 4.0f, 3.0f);
            Assert.IsTrue(ScalarMultiplicationArgument / 2 == new Vector3(2.5f, 2.0f, 1.5f));
            Assert.IsTrue(2 / ScalarMultiplicationArgument == new Vector3(2.5f, 2.0f, 1.5f));

            Vector3 Point3 = new Vector3(12, 18, 24);
            Point3 /= 6;
            Assert.IsTrue(Point3.Equals(new Vector3(2, 3, 4), .01f));
        }
开发者ID:jeske,项目名称:agg-sharp,代码行数:10,代码来源:Vector3DTests.cs

示例7: ScalarMultiplication

        public void ScalarMultiplication()
        {
            Vector3 ScalarMultiplicationArgument = new Vector3(5.0f, 4.0f, 3.0f);
            Assert.IsTrue(ScalarMultiplicationArgument * -.5 == -new Vector3(2.5f, 2.0f, 1.5f));
            Assert.IsTrue(-.5 * ScalarMultiplicationArgument == -new Vector3(2.5f, 2.0f, 1.5f));
            Assert.IsTrue(5 * ScalarMultiplicationArgument == new Vector3(25.0f, 20.0f, 15.0f));

            Vector3 Point3 = new Vector3(2, 3, 4);
            Point3 *= 6;
            Assert.IsTrue(Point3.Equals(new Vector3(12, 18, 24), .01f));
        }
开发者ID:jeske,项目名称:agg-sharp,代码行数:11,代码来源:Vector3DTests.cs

示例8: IsValidTarget

 internal static bool IsValidTarget(Obj_AI_Hero target,
     float range,
     DamageType damageType,
     bool ignoreShields = true,
     Vector3 from = default(Vector3))
 {
     try
     {
         return target.IsValidTarget() &&
                target.Distance(
                    (from.Equals(default(Vector3)) ? ObjectManager.Player.ServerPosition : from), true) <
                Math.Pow((range <= 0 ? Orbwalking.GetRealAutoAttackRange(target) : range), 2) &&
                !Invulnerable.Check(target, damageType, ignoreShields);
     }
     catch (Exception ex)
     {
         Global.Logger.AddItem(new LogItem(ex));
     }
     return false;
 }
开发者ID:juan2202,项目名称:LeagueSharp-Standalones,代码行数:20,代码来源:TargetSelector.cs

示例9: IsValidTarget

 internal static bool IsValidTarget(AIHeroClient target, 
     float range, 
     DamageType damageType,
     bool ignoreShield = true,
     Vector3 from = default(Vector3))
 {
     try
     {
         return target.IsValidTarget() &&
                target.Distance(
                    (from.Equals(default(Vector3)) ? ObjectManager.Player.ServerPosition : from), true) <
                Math.Pow((range <= 0 ? ObjectManager.Player.GetAutoAttackRange(target) : range), 2) &&
                !Invulnerable.Check(target, damageType, ignoreShield );
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
     }
     return false;
 }
开发者ID:himrengod,项目名称:Elobuddy-1,代码行数:20,代码来源:AdvancedTargetSelector.cs

示例10: BlockPlaced

 public override bool BlockPlaced(World world, Vector3 position, Vector3 blockClicked, byte facing, Entities.Entity placedBy)
 {
     Metadata = MathHelper.DirectionByRotationFlat(placedBy);
     switch ((Directions)Metadata)
     {
         case Directions.North:
             Metadata = (byte)StairDirections.North;
             break;
         case Directions.South:
             Metadata = (byte)StairDirections.South;
             break;
         case Directions.West:
             Metadata = (byte)StairDirections.West;
             break;
         case Directions.East:
             Metadata = (byte)StairDirections.East;
             break;
     }
     if (blockClicked.Equals(position + Vector3.Up))
         this.Metadata |= 4;
     return true;
 }
开发者ID:vatt849,项目名称:LibMinecraft,代码行数:22,代码来源:StairsBlock.cs

示例11: OnBlockPlaced

 public override bool OnBlockPlaced(World world, Vector3 position, Vector3 clickedBlock, Vector3 clickedSide, Vector3 cursorPosition, Entities.Entity usedBy)
 {
     Metadata = (byte)MathHelper.DirectionByRotationFlat(usedBy);
     switch ((Direction)Metadata)
     {
         case Direction.North:
             Metadata = (byte)StairDirections.North;
             break;
         case Direction.South:
             Metadata = (byte)StairDirections.South;
             break;
         case Direction.West:
             Metadata = (byte)StairDirections.West;
             break;
         case Direction.East:
             Metadata = (byte)StairDirections.East;
             break;
     }
     if (clickedBlock.Equals(position + Vector3.Up))
         this.Metadata |= 4;
     return true;
 }
开发者ID:ammaraskar,项目名称:Craft.Net,代码行数:22,代码来源:StairBlock.cs

示例12: GetMaxRHits

        private Tuple<List<Obj_AI_Hero>, Vector3> GetMaxRHits(HitChance hitChance, Vector3 fromCheck = default(Vector3))
        {
            if (fromCheck.Equals(default(Vector3)))
            {
                fromCheck = ObjectManager.Player.Position;
            }

            var input = new PredictionInput
            {
                Collision = true,
                CollisionObjects = new[] { CollisionableObjects.YasuoWall },
                From = fromCheck,
                RangeCheckFrom = fromCheck,
                Type = R.Type,
                Radius = R.Width,
                Delay = R.Delay,
                Speed = R.Speed,
                Range = R.Range,
                Aoe = true
            };

            var castPosition = Vector3.Zero;
            var totalHits = new List<Obj_AI_Hero>();
            try
            {
                var positions = new List<CPrediction.Position>();
                foreach (var t in GameObjects.EnemyHeroes)
                {
                    if (t.IsValidTarget(R.Range * 1.5f, true, fromCheck))
                    {
                        input.Unit = t;
                        var prediction = Prediction.GetPrediction(input);
                        if (prediction.Hitchance >= hitChance)
                        {
                            positions.Add(new CPrediction.Position(t, prediction.UnitPosition));
                        }
                    }
                }
                var circle = new Geometry.Polygon.Circle(fromCheck, R.Range).Points;
                foreach (var point in circle)
                {
                    var hits = new List<Obj_AI_Hero>();
                    foreach (var position in positions)
                    {
                        R.UpdateSourcePosition(fromCheck, fromCheck);
                        if (R.WillHit(position.UnitPosition, point.To3D()))
                        {
                            hits.Add(position.Hero);
                        }
                        R.UpdateSourcePosition();
                    }
                    if (hits.Count > totalHits.Count)
                    {
                        castPosition = point.To3D();
                        totalHits = hits;
                    }
                }
            }
            catch (Exception ex)
            {
                Global.Logger.AddItem(new LogItem(ex));
            }
            return new Tuple<List<Obj_AI_Hero>, Vector3>(totalHits, castPosition);
        }
开发者ID:julianrolandi,项目名称:LeagueSharp-Dev,代码行数:64,代码来源:Cassiopeia.cs

示例13: GetHits

        private Tuple<int, List<Obj_AI_Hero>> GetHits(Spell spell,
            float overrideWidth = -1f,
            Vector3 fromCheck = default(Vector3))
        {
            try
            {
                if (fromCheck.Equals(default(Vector3)))
                {
                    fromCheck = Ball.Position;
                }

                var input = new PredictionInput
                {
                    Collision = true,
                    CollisionObjects = new[] { CollisionableObjects.YasuoWall },
                    From = fromCheck,
                    RangeCheckFrom = fromCheck,
                    Type = spell.Type,
                    Radius = spell.Width,
                    Delay = spell.Delay,
                    Speed = spell.Speed,
                    Range = spell.Range,
                    Aoe = true
                };

                var width = overrideWidth > 0 ? overrideWidth : spell.Width;
                var hits = new List<Obj_AI_Hero>();
                var positions = new List<CPrediction.Position>();
                foreach (var t in GameObjects.EnemyHeroes)
                {
                    if (t.IsValidTarget(width * 4, true, fromCheck))
                    {
                        input.Unit = t;
                        var prediction = Prediction.GetPrediction(input);
                        if (prediction.Hitchance >= HitChance.High)
                        {
                            if (Utils.IsImmobile(t) || Utils.IsSlowed(t) || t.Distance(fromCheck) < spell.Width * 0.75 ||
                                t.Distance(fromCheck) < spell.Width &&
                                (fromCheck.Distance(Ball.Position) > 100 || t.IsFacing(fromCheck, 120f)))
                            {
                                positions.Add(new CPrediction.Position(t, prediction.UnitPosition));
                            }
                        }
                    }
                }
                if (positions.Any())
                {
                    var circle = new Geometry.Polygon.Circle(fromCheck, width);
                    hits.AddRange(
                        from position in positions
                        where
                            !position.Hero.IsDashing() ||
                            (position.Hero.Distance(fromCheck) >= 100f &&
                             position.Hero.Position.Distance(fromCheck) >
                             position.Hero.GetDashInfo().EndPos.Distance(fromCheck) - 50f)
                        where circle.IsInside(position.UnitPosition)
                        select position.Hero);
                    return new Tuple<int, List<Obj_AI_Hero>>(hits.Count, hits);
                }
            }
            catch (Exception ex)
            {
                Global.Logger.AddItem(new LogItem(ex));
            }
            return new Tuple<int, List<Obj_AI_Hero>>(0, new List<Obj_AI_Hero>());
        }
开发者ID:jayblah,项目名称:Lizzaran,代码行数:66,代码来源:Orianna.cs

示例14: TestEquality

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

        /// <summary>
        /// Helper method for testing equality.
        /// </summary>
        void TestEquality (Vector3 a, Vector3 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

示例15: ReadMLineSegments

        private List<MLineVertex> ReadMLineSegments(int numVertexes, int numStyleElements, Vector3 normal, out double elevation)
        {
            elevation = 0.0;

            List<MLineVertex> segments = new List<MLineVertex>();
            Matrix3 trans = MathHelper.ArbitraryAxis(normal).Traspose();
            for (int i = 0; i < numVertexes; i++)
            {
                Vector3 vertex = new Vector3();
                vertex.X = this.chunk.ReadDouble(); // code 11
                this.chunk.Next();
                vertex.Y = this.chunk.ReadDouble(); // code 21
                this.chunk.Next();
                vertex.Z = this.chunk.ReadDouble(); // code 31
                this.chunk.Next();

                Vector3 dir = new Vector3();
                dir.X = this.chunk.ReadDouble(); // code 12
                this.chunk.Next();
                dir.Y = this.chunk.ReadDouble(); // code 22
                this.chunk.Next();
                dir.Z = this.chunk.ReadDouble(); // code 32
                this.chunk.Next();

                Vector3 mitter = new Vector3();
                mitter.X = this.chunk.ReadDouble(); // code 13
                this.chunk.Next();
                mitter.Y = this.chunk.ReadDouble(); // code 23
                this.chunk.Next();
                mitter.Z = this.chunk.ReadDouble(); // code 33
                this.chunk.Next();

                List<double>[] distances = new List<double>[numStyleElements];
                for (int j = 0; j < numStyleElements; j++)
                {
                    distances[j] = new List<double>();
                    short numDistances = this.chunk.ReadShort(); // code 74
                    this.chunk.Next();
                    for (short k = 0; k < numDistances; k++)
                    {
                        distances[j].Add(this.chunk.ReadDouble()); // code 41
                        this.chunk.Next();
                    }

                    // no more info is needed, fill parameters are not supported
                    short numFillParams = this.chunk.ReadShort(); // code 75
                    this.chunk.Next();
                    for (short k = 0; k < numFillParams; k++)
                    {
                        //double param = this.chunk.ReadDouble(); // code 42
                        this.chunk.Next();
                    }
                }

                // we need to convert WCS coordinates to OCS coordinates
                if (!normal.Equals(Vector3.UnitZ))
                {
                    vertex = trans*vertex;
                    dir = trans*dir;
                    mitter = trans*mitter;
                }

                MLineVertex segment = new MLineVertex(new Vector2(vertex.X, vertex.Y),
                    new Vector2(dir.X, dir.Y),
                    new Vector2(mitter.X, mitter.Y),
                    distances);
                elevation = vertex.Z;
                segments.Add(segment);
            }

            return segments;
        }
开发者ID:Core2D,项目名称:netdxf,代码行数:72,代码来源:DxfReader.cs


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