/// <summary> /// Returns the intersection of the two AxisAlignedBoundingBox objects if an intersection exists /// </summary> /// <param name="b">AxisAlignedBoundingBox to intersect with this AxisAlignedBoundingBox</param> /// <returns>The intersection of the two AxisAlignedBoundingBox objects</returns> public AxisAlignedBoundingBox Intersection(AxisAlignedBoundingBox b) { Vector3 t_min = min; Vector3 t_max = max; t_min.TakeMax(b.Min); t_max.TakeMin(b.Max); if (t_min.x < t_max.x && t_min.y < t_max.y && t_min.z < t_max.z) { return(new AxisAlignedBoundingBox(t_min, t_max)); } return(null); // Must be no intersection }
/// <summary> /// Returns the intersection of the two AxisAlignedBoundingBox objects if an intersection exists. /// </summary> /// <param name="b">AxisAlignedBoundingBox to intersect with this AxisAlignedBoundingBox.</param> /// <returns>The intersection of the two AxisAlignedBoundingBox objects.</returns> public AxisAlignedBoundingBox Intersection(AxisAlignedBoundingBox b) { Vector3 t_min = min; Vector3 t_max = max; t_min.TakeMax(b.Min); t_max.TakeMin(b.Max); if (t_min.X < t_max.X && t_min.Y < t_max.Y && t_min.Z < t_max.Z) { return(new AxisAlignedBoundingBox(t_min, t_max)); } return(null); // Must be no intersection }
/// <summary> /// Increase the size of the bounding box (if needed) to fit the point within the box /// </summary> /// <param name="Point">The point to fit into the AxisAlignedBoundingBox</param> public void AddPoint(Vector3 Point) { min.TakeMin(Point); max.TakeMax(Point); }