/// <summary> /// Counts points outside axis-aligned box. /// </summary> public static long CountPointsOutsideBox( this PointSetNode self, Box3d query, int minCellExponent = int.MinValue ) => CountPoints(self, n => !query.Intersects(n.BoundingBox), n => query.Contains(n.BoundingBox), p => !query.Contains(p), minCellExponent);
/// <summary> /// All points outside axis-aligned box (excluding boundary). /// </summary> public static IEnumerable <Chunk> QueryPointsOutsideBox( this IPointCloudNode self, Box3d query, int minCellExponent = int.MinValue ) => QueryPoints(self, n => !query.Intersects(n.BoundingBoxExactGlobal), n => query.Contains(n.BoundingBoxExactGlobal), p => !query.Contains(p), minCellExponent);
/// <summary> /// Counts points inside axis-aligned box. /// </summary> public static long CountPointsInsideBox( this IPointCloudNode self, Box3d query, int minCellExponent = int.MinValue ) => CountPoints(self, n => query.Contains(n.BoundingBoxExactGlobal), n => !query.Intersects(n.BoundingBoxExactGlobal), p => query.Contains(p), minCellExponent);
/// <summary> /// All points inside axis-aligned box (including boundary). /// </summary> public static IEnumerable <Chunk> QueryPointsInsideBox( this PointSetNode self, Box3d query, int minCellExponent = int.MinValue ) => QueryPoints(self, n => query.Contains(n.BoundingBox), n => !query.Intersects(n.BoundingBox), p => query.Contains(p), minCellExponent);
public void CanDeletePoints() { var q = new Box3d(new V3d(0.3), new V3d(0.7)); var a = CreateRegularPointsInUnitCube(10, 1); Assert.IsTrue(a.QueryAllPoints().SelectMany(chunk => chunk.Positions).Any(p => q.Contains(p))); var b = a.Delete(n => q.Contains(n.BoundingBox), n => !(q.Contains(n.BoundingBox) || q.Intersects(n.BoundingBox)), p => q.Contains(p), CancellationToken.None); Assert.IsTrue(a.PointCount > b.PointCount); Assert.IsTrue(!b.QueryAllPoints().SelectMany(chunk => chunk.Positions).Any(p => q.Contains(p))); }
private void CreateParticles(Box3d exclusion) { int numX = (int)(Bounds.Width / Diameter); int numY = (int)(Bounds.Height / Diameter); int numZ = (int)(Bounds.Depth / Diameter); Positions = new List <Vector3d>(); for (int z = 0; z < numZ; z++) { for (int y = 0; y < numY; y++) { for (int x = 0; x < numX; x++) { Vector3d pos = new Vector3d(); pos.x = Diameter * x + Bounds.Min.x + Spacing; pos.y = Diameter * y + Bounds.Min.y + Spacing; pos.z = Diameter * z + Bounds.Min.z + Spacing; if (!exclusion.Contains(pos)) { Positions.Add(pos); } } } } }
public void ValidBoxDoesNotContainInvalidBox() { var a = new Box3d(new V3d(0, 0, 0), new V3d(3, 3, 3)); var b = Box3d.Invalid; Assert.IsTrue(!a.Contains(b)); }
public void ValidBoxContainsValidBox() { var a = new Box3d(new V3d(0, 0, 0), new V3d(3, 3, 3)); var b = new Box3d(new V3d(1, 1, 1), new V3d(2, 2, 2)); Assert.IsTrue(a.Contains(b)); }
public void BoxInsideOutside_Contains_OutsideTouching() { var a = new Box3d(new V3d(0, 0, 0), new V3d(4, 4, 4)); var b = new Box3d(new V3d(4, 0, 0), new V3d(8, 4, 4)); Assert.IsTrue(!a.Contains(b)); }
public void BoxInsideOutside_Contains_Inside() { var a = new Box3d(new V3d(0, 0, 0), new V3d(4, 4, 4)); var b = new Box3d(new V3d(1, 1, 2), new V3d(2, 2, 3)); Assert.IsTrue(a.Contains(b)); }
public bool ObjectIsInsideBox( int objectIndex, Box3d box ) { return(box.Contains(Sphere3ds[objectIndex])); }
public void BoxInsideOutside_ContainsEqual() { var a = new Box3d(new V3d(1, 2, 3), new V3d(4, 5, 6)); var b = new Box3d(new V3d(1, 2, 3), new V3d(4, 5, 6)); Assert.IsTrue(a.Contains(b)); Assert.IsTrue(b.Contains(a)); }
public void MarkAsStatic(Box3d bounds) { for (int i = 0; i < NumParticles; i++) { if (bounds.Contains(Positions[i])) { StaticConstraints.Add(new StaticConstraint3d(this, i)); } } }
public bool ObjectIsInsideBox( int objectIndex, Box3d box ) { var pl = Position3dList; int pi = objectIndex * 3; return(box.Contains(new Triangle3d(pl[pi], pl[pi + 1], pl[pi + 2]))); }
public bool ObjectIsInsideBox(int objectIndex, Box3d box) { int[] fia = FirstIndexArray, via = VertexIndexArray; var pa = PositionArray; int fvi = fia[objectIndex], fve = fia[objectIndex + 1]; while (fvi < fve) { if (!box.Contains(pa[via[fvi++]])) { return(false); } } return(true); }
public void CanQueryPointsNearPlane_1() { var pointset = CreateRandomPointsInUnitCube(1024, 64); var q = new Plane3d(V3d.ZAxis, new V3d(0.5, 0.5, 0.5)); var ps = pointset.QueryPointsNearPlane(q, 0.1).SelectMany(x => x.Positions).ToList(); Assert.IsTrue(pointset.PointCount > ps.Count); var bb = new Box3d(new V3d(0.0, 0.0, 0.4), new V3d(1.0, 1.0, 0.6)); foreach (var p in ps) { Assert.IsTrue(bb.Contains(p)); } }
public void CanQueryPointsNotNearPolygon_1() { var pointset = CreateRandomPointsInUnitCube(1024, 64); var q = new Polygon3d(new V3d(0.4, 0.4, 0.5), new V3d(0.6, 0.4, 0.5), new V3d(0.6, 0.6, 0.5), new V3d(0.4, 0.6, 0.5)); var ps = pointset.QueryPointsNotNearPolygon(q, 0.1).SelectMany(x => x.Positions).ToList(); Assert.IsTrue(pointset.PointCount > ps.Count); var bb = new Box3d(new V3d(0.4, 0.4, 0.4), new V3d(0.6, 0.6, 0.6)); foreach (var p in ps) { Assert.IsTrue(!bb.Contains(p)); } }
public void CanQueryPointsNearPlanes_1() { var pointset = CreateRandomPointsInUnitCube(1024, 64); var q = new[] { new Plane3d(V3d.ZAxis, new V3d(0.5, 0.5, 0.5)), new Plane3d(V3d.XAxis, new V3d(0.7, 0.5, 0.5)) }; var ps = pointset.QueryPointsNearPlanes(q, 0.1).SelectMany(x => x.Positions).ToList(); Assert.IsTrue(pointset.PointCount > ps.Count); var bb1 = new Box3d(new V3d(0.0, 0.0, 0.4), new V3d(1.0, 1.0, 0.6)); var bb2 = new Box3d(new V3d(0.6, 0.0, 0.0), new V3d(0.8, 1.0, 1.0)); //var wrongs = ps.Where(p => !bb1.Contains(p) && !bb2.Contains(p)).ToArray(); foreach (var p in ps) { Assert.IsTrue(bb1.Contains(p) || bb2.Contains(p)); } }
public bool ObjectIsInsideBox(int objectIndex, Box3d box) { GetTriangle(objectIndex, out V3d p0, out V3d p1, out V3d p2); return(box.Contains(p0) && box.Contains(p1) && box.Contains(p2)); }
public bool ObjectIsInsideBox(int objectIndex, Box3d box) { var pa = m_positionArray; return(box.Contains(pa[objectIndex]) && box.Contains(pa[objectIndex + 1])); }