public static bool Intersects(ref Bounds3 lhs, ref Bounds3 rhs) { return((rhs.Minimum.X <= lhs.Maximum.X) && (lhs.Minimum.X <= rhs.Maximum.X) && (rhs.Minimum.Y <= lhs.Maximum.Y) && (lhs.Minimum.Y <= rhs.Maximum.Y)); }
public static Bounds3 FromUnion(ref Bounds3 lhs, ref Bounds3 rhs) { var x1 = Math.Min(lhs.Minimum.X, rhs.Minimum.X); var y1 = Math.Min(lhs.Minimum.Y, rhs.Minimum.Y); var z1 = Math.Min(lhs.Minimum.Z, rhs.Minimum.Z); var x2 = Math.Max(lhs.Maximum.X, rhs.Maximum.X); var y2 = Math.Max(lhs.Maximum.Y, rhs.Maximum.Y); var z2 = Math.Max(lhs.Maximum.Z, rhs.Maximum.Z); return(new Bounds3( new Vector3(x1, y1, z1), new Vector3(x2, y2, z2) )); }
public bool Intersection(ref Bounds3 lhs, ref Bounds3 rhs, out Bounds3 result) { var x1 = Math.Max(lhs.Minimum.X, rhs.Minimum.X); var y1 = Math.Max(lhs.Minimum.Y, rhs.Minimum.Y); var z1 = Math.Max(lhs.Minimum.Z, rhs.Minimum.Z); var x2 = Math.Min(lhs.Maximum.X, rhs.Maximum.X); var y2 = Math.Min(lhs.Maximum.Y, rhs.Maximum.Y); var z2 = Math.Max(lhs.Maximum.Z, rhs.Maximum.Z); if (x2 >= x1 && y2 >= y1 && z2 >= z1) { result = new Bounds3( new Vector3(x1, y1, z1), new Vector3(x2, y2, z2) ); return(true); } result = default(Bounds3); return(false); }
public static Polygon3 FromBounds(ref Bounds3 bounds) { var points = new [] { new Vector3(bounds.Minimum.X, bounds.Minimum.Y, bounds.Minimum.Z), new Vector3(bounds.Minimum.X, bounds.Minimum.Y, bounds.Maximum.Z), new Vector3(bounds.Minimum.X, bounds.Maximum.Y, bounds.Minimum.Z), new Vector3(bounds.Minimum.X, bounds.Maximum.Y, bounds.Maximum.Z), new Vector3(bounds.Maximum.X, bounds.Minimum.Y, bounds.Minimum.Z), new Vector3(bounds.Maximum.X, bounds.Minimum.Y, bounds.Maximum.Z), new Vector3(bounds.Maximum.X, bounds.Maximum.Y, bounds.Minimum.Z), new Vector3(bounds.Maximum.X, bounds.Minimum.Y, bounds.Maximum.Z), new Vector3(bounds.Maximum.X, bounds.Maximum.Y, bounds.Maximum.Z), }; return(new Polygon3(points)); }
public static bool DoesLineIntersectCube(Vector3 start, Vector3 end, Bounds3 cube) { var lineProjectionX = ProjectOntoAxis(Vector3.UnitX, start, end); var rectProjectionX = new Interval(cube.Minimum.X, cube.Maximum.X); if (lineProjectionX.Intersects(rectProjectionX)) { return(true); } var lineProjectionY = ProjectOntoAxis(Vector3.UnitY, start, end); var rectProjectionY = new Interval(cube.Minimum.Y, cube.Maximum.Y); if (lineProjectionY.Intersects(rectProjectionY)) { return(true); } var lineProjectionZ = ProjectOntoAxis(Vector3.UnitY, start, end); var rectProjectionZ = new Interval(cube.Minimum.Z, cube.Maximum.Z); return(lineProjectionZ.Intersects(rectProjectionZ)); }
public static Bounds3?FromIntersection(ref Bounds3 lhs, ref Bounds3 rhs) { Vector3 a = Vector3.Zero, b = Vector3.Zero; a.X = Math.Max(lhs.Minimum.X, rhs.Minimum.X); a.Y = Math.Max(lhs.Minimum.Y, rhs.Minimum.Y); a.Z = Math.Max(lhs.Minimum.Z, rhs.Minimum.Z); b.X = Math.Min(lhs.Maximum.X, rhs.Maximum.X); b.Y = Math.Min(lhs.Maximum.Y, rhs.Maximum.Y); b.Z = Math.Min(lhs.Maximum.Z, rhs.Maximum.Z); if ( (b.X > a.X) && (b.Y > a.Y) && (b.Z > a.Z) ) { return(new Bounds3(a, b)); } else { return(null); } }
public bool Contains(ref Bounds3 other) { return((other.Minimum.X >= Minimum.X) && (other.Minimum.Y >= Minimum.Y) && (other.Minimum.Z >= Minimum.Z) && (other.Maximum.X <= Maximum.X) && (other.Maximum.Y <= Maximum.Y) && (other.Maximum.Z <= Maximum.Z)); }
public static Bounds3?FromIntersection(Bounds3 lhs, Bounds3 rhs) { return(FromIntersection(ref lhs, ref rhs)); }
public bool Intersects(Bounds3 rhs) { return(Intersects(ref this, ref rhs)); }
public static Polygon3 FromBounds(Bounds3 bounds) { return(FromBounds(ref bounds)); }