public BoundingBox3 Merge(BoundingBox3 boundingBox2) { BoundingBox3 result; if (Min.X < boundingBox2.Min.X) { result.Min.X = Min.X; } else { result.Min.X = boundingBox2.Min.X; } if (Min.Y < boundingBox2.Min.Y) { result.Min.Y = Min.Y; } else { result.Min.Y = boundingBox2.Min.Y; } if (Min.Z < boundingBox2.Min.Z) { result.Min.Z = Min.Z; } else { result.Min.Z = boundingBox2.Min.Z; } if (Max.X > boundingBox2.Max.X) { result.Max.X = Max.X; } else { result.Max.X = boundingBox2.Max.X; } if (Max.Y > boundingBox2.Max.Y) { result.Max.Y = Max.Y; } else { result.Max.Y = boundingBox2.Max.Y; } if (Max.Z > boundingBox2.Max.Z) { result.Max.Z = Max.Z; } else { result.Max.Z = boundingBox2.Max.Z; } return(result); }
public static void Merge(ref BoundingBox3 boundingBox1, ref BoundingBox3 boundingBox2, out BoundingBox3 result) { if (boundingBox1.Min.X < boundingBox2.Min.X) { result.Min.X = boundingBox1.Min.X; } else { result.Min.X = boundingBox2.Min.X; } if (boundingBox1.Min.Y < boundingBox2.Min.Y) { result.Min.Y = boundingBox1.Min.Y; } else { result.Min.Y = boundingBox2.Min.Y; } if (boundingBox1.Min.Z < boundingBox2.Min.Z) { result.Min.Z = boundingBox1.Min.Z; } else { result.Min.Z = boundingBox2.Min.Z; } if (boundingBox1.Max.X > boundingBox2.Max.X) { result.Max.X = boundingBox1.Max.X; } else { result.Max.X = boundingBox2.Max.X; } if (boundingBox1.Max.Y > boundingBox2.Max.Y) { result.Max.Y = boundingBox1.Max.Y; } else { result.Max.Y = boundingBox2.Max.Y; } if (boundingBox1.Max.Z > boundingBox2.Max.Z) { result.Max.Z = boundingBox1.Max.Z; } else { result.Max.Z = boundingBox2.Max.Z; } }
public bool Intersects(BoundingBox3 boundingBox) { Vector3 clampedLocation; if (Center.X > boundingBox.Max.X) { clampedLocation.X = boundingBox.Max.X; } else if (Center.X < boundingBox.Min.X) { clampedLocation.X = boundingBox.Min.X; } else { clampedLocation.X = Center.X; } if (Center.Y > boundingBox.Max.Y) { clampedLocation.Y = boundingBox.Max.Y; } else if (Center.Y < boundingBox.Min.Y) { clampedLocation.Y = boundingBox.Min.Y; } else { clampedLocation.Y = Center.Y; } if (Center.Z > boundingBox.Max.Z) { clampedLocation.Z = boundingBox.Max.Z; } else if (Center.Z < boundingBox.Min.Z) { clampedLocation.Z = boundingBox.Min.Z; } else { clampedLocation.Z = Center.Z; } return(clampedLocation.DistanceSquared(Center) <= (Radius * Radius)); }
public static void Intersects(ref BoundingSphere3 boundingSphere, ref BoundingBox3 boundingBox, out bool result) { Vector3 clampedLocation; if (boundingSphere.Center.X > boundingBox.Max.X) { clampedLocation.X = boundingBox.Max.X; } else if (boundingSphere.Center.X < boundingBox.Min.X) { clampedLocation.X = boundingBox.Min.X; } else { clampedLocation.X = boundingSphere.Center.X; } if (boundingSphere.Center.Y > boundingBox.Max.Y) { clampedLocation.Y = boundingBox.Max.Y; } else if (boundingSphere.Center.Y < boundingBox.Min.Y) { clampedLocation.Y = boundingBox.Min.Y; } else { clampedLocation.Y = boundingSphere.Center.Y; } if (boundingSphere.Center.Z > boundingBox.Max.Z) { clampedLocation.Z = boundingBox.Max.Z; } else if (boundingSphere.Center.Z < boundingBox.Min.Z) { clampedLocation.Z = boundingBox.Min.Z; } else { clampedLocation.Z = boundingSphere.Center.Z; } result = clampedLocation.DistanceSquared(boundingSphere.Center) <= (boundingSphere.Radius * boundingSphere.Radius); }
public bool Intersects(BoundingBox3 boundingBox) { Vector3 clampedLocation; if (Center.X > boundingBox.Max.X) { clampedLocation.X = boundingBox.Max.X; } else if (Center.X < boundingBox.Min.X) { clampedLocation.X = boundingBox.Min.X; } else { clampedLocation.X = Center.X; } if (Center.Y > boundingBox.Max.Y) { clampedLocation.Y = boundingBox.Max.Y; } else if (Center.Y < boundingBox.Min.Y) { clampedLocation.Y = boundingBox.Min.Y; } else { clampedLocation.Y = Center.Y; } if (Center.Z > boundingBox.Max.Z) { clampedLocation.Z = boundingBox.Max.Z; } else if (Center.Z < boundingBox.Min.Z) { clampedLocation.Z = boundingBox.Min.Z; } else { clampedLocation.Z = Center.Z; } return clampedLocation.DistanceSquared(Center) <= (Radius * Radius); }
public bool Intersects(BoundingBox3 boundingBox) { throw new NotImplementedException(); }
public static void Contains(ref BoundingFrustum3 boundingFrustum, ref BoundingBox3 boundingBox, out ContainmentTypes result) { throw new NotImplementedException(); }
public ContainmentTypes Contains(BoundingBox3 boundingBox) { throw new NotImplementedException(); }
public static void Intersects(ref BoundingFrustum3 boundingFrustum, ref BoundingBox3 boundingBox, out bool result) { throw new NotImplementedException(); }
public static void Merge(ref BoundingBox3 boundingBox1, ref BoundingBox3 boundingBox2, out BoundingBox3 result) { if (boundingBox1.Min.X < boundingBox2.Min.X) result.Min.X = boundingBox1.Min.X; else result.Min.X = boundingBox2.Min.X; if (boundingBox1.Min.Y < boundingBox2.Min.Y) result.Min.Y = boundingBox1.Min.Y; else result.Min.Y = boundingBox2.Min.Y; if (boundingBox1.Min.Z < boundingBox2.Min.Z) result.Min.Z = boundingBox1.Min.Z; else result.Min.Z = boundingBox2.Min.Z; if (boundingBox1.Max.X > boundingBox2.Max.X) result.Max.X = boundingBox1.Max.X; else result.Max.X = boundingBox2.Max.X; if (boundingBox1.Max.Y > boundingBox2.Max.Y) result.Max.Y = boundingBox1.Max.Y; else result.Max.Y = boundingBox2.Max.Y; if (boundingBox1.Max.Z > boundingBox2.Max.Z) result.Max.Z = boundingBox1.Max.Z; else result.Max.Z = boundingBox2.Max.Z; }
public bool Intersects(BoundingBox3 boundingBox) { return !(boundingBox.Min.X > Max.X || boundingBox.Min.Y > Max.Y || boundingBox.Min.Z > Max.Z || Min.X > boundingBox.Max.X || Min.Y > boundingBox.Max.Y || Min.Z > boundingBox.Max.Z); }
public BoundingBox3 Merge(BoundingBox3 boundingBox2) { BoundingBox3 result; if (Min.X < boundingBox2.Min.X) result.Min.X = Min.X; else result.Min.X = boundingBox2.Min.X; if (Min.Y < boundingBox2.Min.Y) result.Min.Y = Min.Y; else result.Min.Y = boundingBox2.Min.Y; if (Min.Z < boundingBox2.Min.Z) result.Min.Z = Min.Z; else result.Min.Z = boundingBox2.Min.Z; if (Max.X > boundingBox2.Max.X) result.Max.X = Max.X; else result.Max.X = boundingBox2.Max.X; if (Max.Y > boundingBox2.Max.Y) result.Max.Y = Max.Y; else result.Max.Y = boundingBox2.Max.Y; if (Max.Z > boundingBox2.Max.Z) result.Max.Z = Max.Z; else result.Max.Z = boundingBox2.Max.Z; return result; }
public bool Intersects(BoundingBox3 boundingBox) { return (!(boundingBox.Min.X > Max.X || boundingBox.Min.Y > Max.Y || boundingBox.Min.Z > Max.Z || Min.X > boundingBox.Max.X || Min.Y > boundingBox.Max.Y || Min.Z > boundingBox.Max.Z)); }
public static void Intersects(ref BoundingBox3 boundingBox1, ref BoundingBox3 boundingBox2, out bool result) { result = !(boundingBox1.Min.X > boundingBox2.Max.X || boundingBox1.Min.Y > boundingBox2.Max.Y || boundingBox1.Min.Z > boundingBox2.Max.Z || boundingBox2.Min.X > boundingBox1.Max.X || boundingBox2.Min.Y > boundingBox1.Max.Y || boundingBox2.Min.Z > boundingBox1.Max.Z); }
public bool Intersects(ref BoundingBox3 boundingBox, out float result) { // X if (Math.Abs(Direction.X) < MathUtilities.Epsilon && (Origin.X < boundingBox.Min.X || Origin.X > boundingBox.Max.X)) { //If the ray isn't pointing along the axis at all, and is outside of the box's interval, then it can't be intersecting. result = 0; return(false); } float tmin = 0, tmax = float.MaxValue; float inverseDirection = 1 / Direction.X; float t1 = (boundingBox.Min.X - Origin.X) * inverseDirection; float t2 = (boundingBox.Max.X - Origin.X) * inverseDirection; if (t1 > t2) { float temp = t1; t1 = t2; t2 = temp; } tmin = Math.Max(tmin, t1); tmax = Math.Min(tmax, t2); if (tmin > tmax) { result = 0; return(false); } // Y if (Math.Abs(Direction.Y) < MathUtilities.Epsilon && (Origin.Y < boundingBox.Min.Y || Origin.Y > boundingBox.Max.Y)) { //If the ray isn't pointing along the axis at all, and is outside of the box's interval, then it can't be intersecting. result = 0; return(false); } inverseDirection = 1 / Direction.Y; t1 = (boundingBox.Min.Y - Origin.Y) * inverseDirection; t2 = (boundingBox.Max.Y - Origin.Y) * inverseDirection; if (t1 > t2) { float temp = t1; t1 = t2; t2 = temp; } tmin = Math.Max(tmin, t1); tmax = Math.Min(tmax, t2); if (tmin > tmax) { result = 0; return(false); } // Z if (Math.Abs(Direction.Z) < MathUtilities.Epsilon && (Origin.Z < boundingBox.Min.Z || Origin.Z > boundingBox.Max.Z)) { //If the ray isn't pointing along the axis at all, and is outside of the box's interval, then it can't be intersecting. result = 0; return(false); } inverseDirection = 1 / Direction.Z; t1 = (boundingBox.Min.Z - Origin.Z) * inverseDirection; t2 = (boundingBox.Max.Z - Origin.Z) * inverseDirection; if (t1 > t2) { float temp = t1; t1 = t2; t2 = temp; } tmin = Math.Max(tmin, t1); tmax = Math.Min(tmax, t2); if (tmin > tmax) { result = 0; return(false); } result = tmin; return(true); }