public void BoxInsideOutside_Intersects_OutsideTouchingMax() { 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.Intersects(b)); }
/// <summary> /// Counts points approximately outside axis-aligned box (cell granularity). /// Result is always equal or greater than exact number. /// Faster than CountPointsOutsideBox. /// </summary> public static long CountPointsApproximatelyOutsideBox( this IPointCloudNode self, Box3d query, int minCellExponent = int.MinValue ) => CountPointsApproximately(self, n => !query.Intersects(n.BoundingBoxExactGlobal), n => query.Contains(n.BoundingBoxExactGlobal), minCellExponent);
public bool ObjectIntersectsBox( int objectIndex, Box3d box ) { return(box.Intersects(Sphere3ds[objectIndex])); }
public void ContainedBoxesDoIntersect() { 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.Intersects(b)); }
/// <summary> /// Counts points approximately inside axis-aligned box (cell granularity). /// Result is always equal or greater than exact number. /// Faster than CountPointsInsideBox. /// </summary> public static long CountPointsApproximatelyInsideBox( this PointSetNode self, Box3d query, int minCellExponent = int.MinValue ) => CountPointsApproximately(self, n => query.Contains(n.BoundingBox), n => !query.Intersects(n.BoundingBox), minCellExponent);
public void TouchingBoxesDoNotIntersect() { var a = new Box3d(new V3d(0, 0, 0), new V3d(1, 1, 1)); var b = new Box3d(new V3d(1, 0, 0), new V3d(2, 1, 1)); Assert.IsTrue(!a.Intersects(b)); }
public void ValidBoxDoesNotIntersectInvalidBox() { var a = new Box3d(new V3d(0, 0, 0), new V3d(1, 1, 1)); var b = Box3d.Invalid; Assert.IsTrue(!a.Intersects(b)); }
/// <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> /// 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 bool ObjectIntersectsBox( int objectIndex, Box3d box ) { var pl = Position3dList; int pi = objectIndex * 3; return(box.Intersects(new Triangle3d(pl[pi], pl[pi + 1], pl[pi + 2]))); }
/// <summary> /// Clips given ray on box, or returns null if ray does not intersect box. /// </summary> private static Line3d?Clip(Box3d box, Ray3d ray0) { ray0.Direction = ray0.Direction.Normalized; if (!box.Intersects(ray0, out double t0)) { return(null); } var p0 = ray0.GetPointOnRay(t0); var ray1 = new Ray3d(ray0.GetPointOnRay(t0 + box.Size.Length), -ray0.Direction); if (!box.Intersects(ray1, out double t1)) { throw new InvalidOperationException(); } var p1 = ray1.GetPointOnRay(t1); return(new Line3d(p0, p1)); }
public void BoxIntersectsTriangleTest() { Box3d box = new Box3d(); // Triangle is inside box Triangle t = new Triangle(new Point3d(0, 0, 0), new Point3d(0.2, -0.1, 0), new Point3d(0, -0.2, -0.1)); Assert.IsTrue(box.Intersects(t)); // Triangle is outside of box t = new Triangle(new Point3d(1, 1, 1), new Point3d(2, 1, 1), new Point3d(1, 2, 1)); Assert.IsFalse(box.Intersects(t)); // Triangle touches box t = new Triangle(new Point3d(0.5, 0, 0), new Point3d(0.7, -0.1, 0), new Point3d(0.8, -0.2, -0.1)); Assert.IsTrue(box.Intersects(t)); // Triangle intersects box t = new Triangle(new Point3d(-1, -1, 0), new Point3d(0.7, 0.9, 0.1), new Point3d(0.8, -2, -0.1)); Assert.IsTrue(box.Intersects(t)); }
public bool ObjectIntersectsBox(int objectIndex, Box3d box) { return(box.Intersects(m_boxes[objectIndex])); }
/// <summary></summary> public bool IsFullyOutside(Box3d box) { return(!box.Intersects(m_sphere)); }
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))); }
public void BoxDoesIntersectItself() { var a = new Box3d(new V3d(1, 2, 3), new V3d(4, 5, 6)); Assert.IsTrue(a.Intersects(a)); }