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


C# BoundingBox.Contains方法代码示例

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


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

示例1: TestVarious

		public void TestVarious()
		{
			BoundingBox b1 = new BoundingBox(20, 30, 40, 55);
			Assert.AreEqual(20, b1.Left);
			Assert.AreEqual(20, b1.Min.X);
			Assert.AreEqual(40, b1.Right);
			Assert.AreEqual(40, b1.Max.X);
			Assert.AreEqual(30, b1.Bottom);
			Assert.AreEqual(30, b1.Min.Y);
			Assert.AreEqual(55, b1.Top);
			Assert.AreEqual(55, b1.Max.Y);
			Assert.AreEqual(20, b1.Width);
			Assert.AreEqual(25, b1.Height);
			Assert.AreNotSame(b1, b1.Clone());
			Assert.IsTrue(b1.Contains(new Point(30, 40)));
			Assert.IsTrue(b1.Contains(new Point(20, 40)));
			Assert.IsFalse(b1.Contains(new Point(10, 10)));
			Assert.IsFalse(b1.Contains(new Point(50, 60)));
			Assert.IsFalse(b1.Contains(new Point(30, 60)));
			Assert.IsFalse(b1.Contains(new Point(50, 40)));
			Assert.IsFalse(b1.Contains(new Point(30, 15)));
			Assert.IsTrue(b1.Equals(new BoundingBox(20, 30, 40, 55)));
			Assert.AreEqual(new Point(30, 42.5), b1.GetCentroid());
			Assert.AreEqual(1, b1.LongestAxis);
			Assert.AreEqual(new BoundingBox(19, 29, 41, 56), b1.Grow(1));
			Assert.IsFalse(b1.Equals(null));
			Assert.IsFalse(b1.Equals((object)new Polygon()));
			Assert.AreEqual("20,30 40,55", b1.ToString());
			Assert.AreEqual(b1,new BoundingBox(40,55,20,30));
			Assert.AreEqual(Math.Sqrt(200), b1.Distance(new BoundingBox(50,65,60,75)));
		}
开发者ID:lishxi,项目名称:_SharpMap,代码行数:31,代码来源:BoundingBoxTests.cs

示例2: TestEntitySearching

 public void TestEntitySearching()
 {
     AddMockEntities(50000);
     var entityToFind = _mockEntities.First();
     var pos = entityToFind.Position;
     var pointMin = new Vector3(pos.X - 100, pos.Y - 100, float.MinValue);
     var pointMax = new Vector3(pos.X + 100, pos.Y + 100, float.MaxValue);
     var searchbound = new BoundingBox(pointMin, pointMax);
     var res = _tree.FindEntities(x => searchbound.Contains(x.Position) == ContainmentType.Contains, searchbound);
     Assert.AreEqual(true, res.Contains(entityToFind));
 }
开发者ID:hanson-huang,项目名称:Encore,代码行数:11,代码来源:DynamicQuadTreeTest.cs

示例3: Update

        public override void Update()
        {
            if (ShipController == null) return;

            if ((ShipController.PositionComp.GetPosition() - m_destination).Dot(m_direction) > 0.0f)
            {
                BoundingBox playerBox = new BoundingBox(Vector3.MaxValue, Vector3.MinValue);
                MyEntities.GetInflatedPlayerBoundingBox(ref playerBox, MyNeutralShipSpawner.NEUTRAL_SHIP_FORBIDDEN_RADIUS);

                if (playerBox.Contains(ShipController.PositionComp.GetPosition()) != ContainmentType.Contains)
                {
                    var shipGroup = MyCubeGridGroups.Static.Logical.GetGroup(ShipController.CubeGrid);
                    foreach (var node in shipGroup.Nodes)
                    {
                        node.NodeData.SyncObject.SendCloseRequest();
                    }
                }
            }
        }
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:19,代码来源:MySimpleAutopilot.cs

示例4: ExecuteIntersectionQueryReturnsExpectedFeatures

        public void ExecuteIntersectionQueryReturnsExpectedFeatures()
        {
            DataTable source = createDataTableSource();
            DataTablePoint provider = new DataTablePoint(source, "oid", "x", "y");

            BoundingBox query = new BoundingBox(400, 400, 600, 600);

            FeatureDataTable expected = new FeatureDataTable();
            expected.TableName = "PointSource";

            foreach (DataColumn column in source.Columns)
            {
                expected.Columns.Add(column.ColumnName, column.DataType);
            }

            foreach (DataRowView rowView in source.DefaultView)
            {
                if (query.Contains(new Point((double) rowView["x"], (double) rowView["y"])))
                {
                    expected.ImportRow(rowView.Row);
                }
            }

            FeatureDataSet dataSet = new FeatureDataSet();
            provider.ExecuteIntersectionQuery(query, dataSet);
            Assert.IsNotNull(dataSet);
            Assert.IsNotNull(dataSet.Tables);
            Assert.AreEqual(1, dataSet.Tables.Count);

            FeatureDataTable actual = dataSet.Tables[0];

            Assert.AreEqual(expected.Rows.Count, actual.Rows.Count);

            foreach (DataRowView expectedRowView in expected.DefaultView)
            {
                DataRow[] actualRows = actual.Select("oid = " + expectedRowView["oid"]);
                Assert.AreEqual(1, actualRows.Length);
                Assert.AreEqual(expectedRowView["oid"], actualRows[0]["oid"]);
                Assert.AreEqual(expectedRowView["x"], actualRows[0]["x"]);
                Assert.AreEqual(expectedRowView["y"], actualRows[0]["y"]);
            }
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:42,代码来源:DataTablePointTests.cs

示例5: AddMountForShape

 private HkdBreakableShape AddMountForShape(HkdBreakableShape shape, Matrix transform, ref BoundingBox blockBB)
 {
     Vector4 min;
     Vector4 max;
     shape.GetShape().GetLocalAABB(0.01f, out min, out max);//.Transform(CubeGrid.PositionComp.WorldMatrix);
     var bb = new BoundingBox(new Vector3(min), new Vector3(max));
     bb = bb.Transform(transform);
     bb.Min /= CubeGrid.GridSize; //normalize for mount point
     bb.Max /= CubeGrid.GridSize;
     
     bb.Inflate(0.04f);//add tolerance (fracture shapes are smaller than block)
     bb.Min += blockBB.HalfExtents;
     bb.Max += blockBB.HalfExtents;
     
     if (blockBB.Contains(bb) == ContainmentType.Intersects)
     {
         bb.Inflate(-0.04f);
         foreach (var directionEnum in Base6Directions.EnumDirections)
         {
             int dirEnum = (int)directionEnum;
             Vector3 direction = Base6Directions.Directions[dirEnum];
             Vector3 absDir = Vector3.Abs(direction);
             var mp = new MyCubeBlockDefinition.MountPoint();
             mp.Start = bb.Min;
             mp.End = bb.Max;
             var start = mp.Start * absDir / (blockBB.HalfExtents * 2) - absDir * 0.04f;
             var end = mp.End * absDir / (blockBB.HalfExtents * 2) + absDir * 0.04f;
             bool add = false;
             bool one = false;
             if (start.Max() < 1 && end.Max() > 1 && direction.Max() > 0)
             {
                 add = true;
                 one = true;
             }
             else if (start.Min() < 0 && end.Max() > 0 && direction.Min() < 0)
             {
                 add = true;
             }
             if (!add)
             {
                 continue;
             }
             mp.Start -= mp.Start * absDir - absDir * 0.04f;
             mp.End -= mp.End * absDir + absDir * 0.04f;
             if (one)
             {
                 mp.Start += absDir * blockBB.HalfExtents * 2;
                 mp.End += absDir * blockBB.HalfExtents * 2;
             }
             mp.Start -= blockBB.HalfExtents - Vector3.One / 2;
             mp.End -= blockBB.HalfExtents - Vector3.One / 2;
             mp.Normal = new Vector3I(direction);
             MountPoints.Add(mp);
         }
     }
     return shape;
 }
开发者ID:leandro1129,项目名称:SpaceEngineers,代码行数:57,代码来源:MyFracturedBlock.cs

示例6: TestVector4Containment

        public void TestVector4Containment()
        {
            BoundingBox target = new BoundingBox(-10, -10, -10, 10, 10, 10);
            Vector4 point = new Vector4(-6.66666f, 7.8989898989f, -3f, -27.56999f);
            Vector4 failPoint = new Vector4(4.3555f, -10.00001f, 5.271f, -1000.334f);
            Vector4 pointExpected = point;
            Vector4 failPointExpected = failPoint;

            bool expected = true;
            bool actual;
            actual = target.Contains(ref point);

            bool failExpected = false;
            bool failActual;
            failActual = target.Contains(ref failPoint);

            Assert.AreEqual(pointExpected, point);
            Assert.AreEqual(expected, actual);
            Assert.AreEqual(failPointExpected, failPoint);
            Assert.AreEqual(failExpected, failActual);
        }
开发者ID:Zakkgard,项目名称:WCell,代码行数:21,代码来源:GraphicsTest.cs

示例7: IsPlayerNearby

        private bool IsPlayerNearby()
        {
            BoundingBox playerBox = new BoundingBox(Vector3.MaxValue, Vector3.MinValue);
            MyEntities.GetInflatedPlayerBoundingBox(ref playerBox, MyNeutralShipSpawner.NEUTRAL_SHIP_FORBIDDEN_RADIUS);

            if (playerBox.Contains(ShipController.PositionComp.GetPosition()) == ContainmentType.Contains)
                return true;
            return false;
        }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:9,代码来源:MySimpleAutopilot.cs

示例8: TestBoxContainment

        public void TestBoxContainment()
        {
            BoundingBox target = new BoundingBox(-10, -10, -10, 10, 10, 10);
            BoundingBox containedBox = new BoundingBox(-5, -5, -5, 5, 5, 5);
            BoundingBox intersectsBox = new BoundingBox(5, 5, 5, 15, 15, 15);
            BoundingBox containedBoxExpected = containedBox;
            BoundingBox intersectsBoxExpected = intersectsBox;

            bool containedExpected = true;
            bool containedActual;
            containedActual = target.Contains(ref containedBox);

            bool intersectsExpected = false;
            bool intersectsActual;
            intersectsActual = target.Contains(ref intersectsBox);

            Assert.AreEqual(containedBoxExpected, containedBox);
            Assert.AreEqual(containedExpected, containedActual);
            Assert.AreEqual(intersectsBoxExpected, intersectsBox);
            Assert.AreEqual(intersectsExpected, intersectsActual);
        }
开发者ID:Zakkgard,项目名称:WCell,代码行数:21,代码来源:GraphicsTest.cs

示例9: TestVector3Containment

        public void TestVector3Containment()
        {
            BoundingBox target = new BoundingBox(-10, -10, -10, 10, 10, 10);
            Vector3 point = new Vector3(-2.4432f, 7f, 4.55025f);
            Vector3 failPoint = new Vector3(-5.8f, 10.0001f, 0.4445f);
            Vector3 pointExpected = point;
            Vector3 failPointExpected = failPoint;

            bool expected = true;
            bool actual;
            actual = target.Contains(ref point);

            bool failExpected = false;
            bool failActual;
            failActual = target.Contains(ref failPoint);

            Assert.AreEqual(pointExpected, point);
            Assert.AreEqual(expected, actual);
            Assert.AreEqual(failPointExpected, failPoint);
            Assert.AreEqual(failExpected, failActual);
        }
开发者ID:Zakkgard,项目名称:WCell,代码行数:21,代码来源:GraphicsTest.cs

示例10: IsVisibleInExtent

 public bool IsVisibleInExtent(BoundingBox t)
 {
     if (t == null) return false;
     if (position != null)
         return t.Contains(new SharpMap.Geometries.Point { Y = position.Latitude, X = position.Longitude });
     return !points.Any() || points.Any(k => t.Contains(new SharpMap.Geometries.Point { Y = k.Y, X = k.X }));
 }
开发者ID:TNOCS,项目名称:csTouch,代码行数:7,代码来源:BaseContent.cs

示例11: Contains

        public static void Contains(ref BoundingFrustum boundingFrustum, ref BoundingBox boundingBox, out ContainmentType result)
        {
            var planes = boundingFrustum.GetPlanes();
            var intersects = false;

            for (var i = 0; i < BoundingFrustum.PlaneCount; ++i)
            {
                var planeIntersectionType = boundingBox.Contains(planes[i]);
                switch (planeIntersectionType)
                {
                    case PlaneIntersectionType.Front:
                        result = ContainmentType.Disjoint;
                        return;

                    case PlaneIntersectionType.Intersecting:
                        intersects = true;
                        break;
                }
            }

            result = intersects ? ContainmentType.Intersects : ContainmentType.Contains;
        }
开发者ID:mrG7,项目名称:Nine.Geometry,代码行数:22,代码来源:Intersection.cs

示例12: RecreateWaypointsAroundMadelyn

        /// <summary>
        /// Create and connect waypoints to enable navigation outside prefab containers.
        /// Needs to be called from the main thread (because it uses MyEntities.GetSafeIterationHelperForAll).
        /// </summary>
        public static void RecreateWaypointsAroundMadelyn()
        {
            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("RecreateWaypointsAroundMadelyn");

            // counters for debugging
            int largeObjects = 0;
            int totalWaypointsOutside = 0;
            int bigSubdivisions = 0;
            int closed = 0;

            var envelopes = new List<MyWayPoint[, ,]>();
            var envelopeEntity = new List<MyEntity>();
            var envelopeBvh = new MyDynamicAABBTree(MyConstants.GAME_PRUNING_STRUCTURE_AABB_EXTENSION);

            var nonFree = new HashSet<MyWayPoint>();

            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("create envelope");

            int madelynsBox = -1;
            // create envelopes
            {
                var entity = MyEntities.GetEntityByName("Madelyn");

                entity.UpdateAABBHr();
                BoundingBox box = entity.WorldAABBHr;
                if (box.Max - box.Min == Vector3.Zero)
                    box = entity.WorldAABB;

                // enlarge by 1% and 15 meters on each side
                BoundingBox extrudedBox = new BoundingBox(box.Min - (box.Max - box.Min) * 0.01f - new Vector3(15, 15, 15), box.Max + (box.Max - box.Min) * 0.01f + new Vector3(15, 15, 15));

                var waypointsOutside = new HashSet<MyWayPoint>();

                MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("find crossing");
                // add all edges that cross the non-extruded box from inside to outside (remember out-vertices)
                foreach (var waypoint in MyGamePruningStructure.GetAllEntitiesInBox(ref extrudedBox, MyGamePruningStructure.QueryFlags.Waypoints))
                {
                    var v = waypoint as MyWayPoint;
                    if (!v.Save) continue;
                    nonFree.Add(v);
                    using (MyWayPoint.NeighborsLock.AcquireSharedUsing())
                    {
                        foreach (var n in v.Neighbors)
                            if (n.Save && extrudedBox.Contains(n.Position) != ContainmentType.Contains)
                            {
                                if (waypointsOutside.Add(n)) totalWaypointsOutside++;
                                nonFree.Add(n);
                            }
                    }
                }
                MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();

                // create envelope
                int s = 1;
                if (waypointsOutside.Count > 0 || entity as MyStaticAsteroid == null)  // voxel maps and prefabs are automatically subdivided more
                {
                    s = 2;
                    bigSubdivisions++;
                }
                MyWayPoint[, ,] envelope = new MyWayPoint[s + 1, s + 1, s + 1];

                for (int i = 0; i <= s; i++) for (int j = 0; j <= s; j++) for (int k = 0; k <= s; k++)
                {
                    if (s == 2 && i == 1 && j == 1 && k == 1) continue;
                    envelope[i, j, k] = CreateWaypoint(new Vector3(
                        extrudedBox.Min.X + i * (extrudedBox.Max.X - extrudedBox.Min.X) / s,
                        extrudedBox.Min.Y + j * (extrudedBox.Max.Y - extrudedBox.Min.Y) / s,
                        extrudedBox.Min.Z + k * (extrudedBox.Max.Z - extrudedBox.Min.Z) / s
                    ), null);
                    envelope[i, j, k].Save = false;  // don't save generated waypoints
                    nonFree.Add(envelope[i, j, k]);

                    // assume Madelyn's envelope has no blockers
                    if (i != 0) if (!(s == 2 && i - 1 == 1 && j == 1 && k == 1)) MyWayPoint.Connect(envelope[i, j, k], envelope[i - 1, j, k]);
                    if (j != 0) if (!(s == 2 && j - 1 == 1 && i == 1 && k == 1)) MyWayPoint.Connect(envelope[i, j, k], envelope[i, j - 1, k]);
                    if (k != 0) if (!(s == 2 && k - 1 == 1 && j == 1 && i == 1)) MyWayPoint.Connect(envelope[i, j, k], envelope[i, j, k - 1]);

                    // if it's a part of a face that faces an out-vertex, connect it
                    foreach (var v in waypointsOutside)
                        if ((i == 0 && v.Position.X <= envelope[i, j, k].Position.X) ||
                            (i == s && v.Position.X >= envelope[i, j, k].Position.X) ||
                            (j == 0 && v.Position.Y <= envelope[i, j, k].Position.Y) ||
                            (j == s && v.Position.Y >= envelope[i, j, k].Position.Y) ||
                            (k == 0 && v.Position.Z <= envelope[i, j, k].Position.Z) ||
                            (k == s && v.Position.Z >= envelope[i, j, k].Position.Z)
                        )
                        {
                            MyWayPoint.Connect(v, envelope[i, j, k]);
                        }
                }

                envelopes.Add(envelope);
                envelopeEntity.Add(entity);
                envelopeBvh.AddProxy(ref extrudedBox, envelopes.Count - 1, 0);
                largeObjects++;

//.........这里部分代码省略.........
开发者ID:Bunni,项目名称:Miner-Wars-2081,代码行数:101,代码来源:MyWayPointGraph.cs

示例13: ContainsTest

		public void ContainsTest()
		{
			BoundingBox b1 = new BoundingBox(20, 30, 40, 55);
			Assert.IsTrue(b1.Contains(new Point(30, 40)));
			Assert.IsTrue(b1.Contains(new Point(20, 40)));
			Assert.IsFalse(b1.Contains(new Point(10, 10)));
			Assert.IsFalse(b1.Contains(new Point(50, 60)));
			Assert.IsFalse(b1.Contains(new Point(30, 60)));
			Assert.IsFalse(b1.Contains(new Point(50, 40)));
			Assert.IsFalse(b1.Contains(new Point(30, 15)));
		}
开发者ID:sridhar19091986,项目名称:sharpmapcf,代码行数:11,代码来源:BoundingBoxTests.cs

示例14: IsContainedIn

 public bool IsContainedIn(BoundingBox box)
 {
     return box.Contains(this);
 }
开发者ID:ZombineDev,项目名称:KDTreesWPF,代码行数:4,代码来源:Triangle.cs

示例15: ShapesInside

		private IEnumerable<Shape> ShapesInside(BoundingBox<Coord> bbox, Shape panel = null)
		{
			foreach (var shape in _doc.Shapes)
			{
				if (shape != panel && bbox.Contains(shape.BBox))
					yield return shape;
			}
		}
开发者ID:qwertie,项目名称:ecsharp,代码行数:8,代码来源:DiagramGestureAnalyzer.cs


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