public Box3 Intersect(Box3 box) { this.min.Max(box.min); this.max.Min(box.max); // ensure that if there is no overlap, the result is fully empty, not slightly empty with non-inf/+inf values that will cause subsequence intersects to erroneously return valid values. if (this.IsEmpty()) { this.MakeEmpty(); } return(this); }
public Box3 GetBoundingBox(Box3 target = null) { if (target == null) { Console.WriteLine("THREE.Sphere: .getBoundingBox() target is now required"); target = new Box3(); } target.Set(this.center, this.center); target.ExpandByScalar(this.radius); return(target); }
public bool IntersectsBox(Box3 box) { var p = new Vector3(); var planes = this.planes; for (var i = 0; i < 6; i++) { var plane = planes[i]; // corner at max distance p.x = plane.normal.x > 0 ? box.max.x : box.min.x; p.y = plane.normal.y > 0 ? box.max.y : box.min.y; p.z = plane.normal.z > 0 ? box.max.z : box.min.z; if (plane.DistanceToPoint(p) < 0) { return(false); } } return(true); }
public bool IntersectsBox(Box3 box) { return(box.IntersectsSphere(this)); }
public bool Equals(Box3 box) { return(box.min.Equals(this.min) && box.max.Equals(this.max)); }
public bool ContainsBox(Box3 box) { return(this.min.x <= box.min.x && box.max.x <= this.max.x && this.min.y <= box.min.y && box.max.y <= this.max.y && this.min.z <= box.min.z && box.max.z <= this.max.z); }
public bool IntersectsBox(Box3 box) { var v = new Vector3(); return(this.IntersectBox(box, v) != null); }
public Vector3 IntersectBox(Box3 box, Vector3 target) { double tmin, tmax, tymin, tymax, tzmin, tzmax; double invdirx = 1 / this.direction.x, invdiry = 1 / this.direction.y, invdirz = 1 / this.direction.z; var origin = this.origin; if (invdirx >= 0) { tmin = (box.min.x - origin.x) * invdirx; tmax = (box.max.x - origin.x) * invdirx; } else { tmin = (box.max.x - origin.x) * invdirx; tmax = (box.min.x - origin.x) * invdirx; } if (invdiry >= 0) { tymin = (box.min.y - origin.y) * invdiry; tymax = (box.max.y - origin.y) * invdiry; } else { tymin = (box.max.y - origin.y) * invdiry; tymax = (box.min.y - origin.y) * invdiry; } if ((tmin > tymax) || (tymin > tmax)) { return(null); } // These lines also handle the case where tmin or tmax is NaN // (result of 0 * Infinity). x !== x returns true if x is NaN if (tymin > tmin || double.IsNaN(tmin)) { tmin = tymin; } if (tymax < tmax || double.IsNaN(tmax)) { tmax = tymax; } if (invdirz >= 0) { tzmin = (box.min.z - origin.z) * invdirz; tzmax = (box.max.z - origin.z) * invdirz; } else { tzmin = (box.max.z - origin.z) * invdirz; tzmax = (box.min.z - origin.z) * invdirz; } if ((tmin > tzmax) || (tzmin > tmax)) { return(null); } if (tzmin > tmin || double.IsNaN(tmin)) { tmin = tzmin; } if (tzmax < tmax || double.IsNaN(tmax)) { tmax = tzmax; } //return point closest to the ray (positive side) if (tmax < 0) { return(null); } return(this.At(tmin >= 0 ? tmin : tmax, target)); }
public bool IntersectsBox(Box3 box) { return(box.IntersectsPlane(this)); }
public bool equals(Box3 bb) { throw new NotImplementedException(); }
bool isIntersectionBox(Box3 box) { throw new NotImplementedException(); }
public bool IntersectsBox(Box3 box) { return(box.IntersectsTriangle(this)); }