/// <summary> /// Gets the result of space cross of the box. /// </summary> /// <param name="box1"></param> /// <param name="box2"></param> /// <returns></returns> public static bool CrossSpaceBox(this BoundingBoxXYZ box1, BoundingBoxXYZ box2) { if (box1 is null) { throw new ArgumentNullException(nameof(box1)); } if (box2 is null) { throw new ArgumentNullException(nameof(box2)); } box1 = box1.GetRoundBox(); box2 = box2.GetRoundBox(); var cp1 = (box1.Min - box2.Min).CrossProduct(box2.Max - box2.Min); var cp2 = (box2.Max - box2.Min).CrossProduct(box1.Max - box2.Min); var cp3 = (box2.Min - box1.Min).CrossProduct(box1.Max - box1.Min); var cp4 = (box1.Max - box1.Min).CrossProduct(box2.Max - box1.Min); return(cp1.DotProduct(cp2) > 10e-6 && cp3.DotProduct(cp4) > 10e-6); }
/// <summary> /// Gets the result of fast space rejection of the box. /// </summary> /// <param name="box1"></param> /// <param name="box2"></param> /// <returns></returns> public static bool RejectSpaceBox(this BoundingBoxXYZ box1, BoundingBoxXYZ box2) { if (box1 is null) { throw new ArgumentNullException(nameof(box1)); } if (box2 is null) { throw new ArgumentNullException(nameof(box2)); } box1 = box1.GetRoundBox(); box2 = box2.GetRoundBox(); var v1 = box1.Min.X <= box2.Max.X; var v2 = box1.Max.X >= box2.Min.X; var v3 = box1.Min.Y <= box2.Max.Y; var v4 = box1.Max.Y >= box2.Min.Y; var v5 = box1.Min.Z <= box2.Max.Z; var v6 = box1.Max.Z >= box2.Min.Z; return(v1 && v2 && v3 && v4 && v5 && v6); }
/// <summary> /// Gets the result of plane cross of the box. /// </summary> /// <param name="box1"></param> /// <param name="box2"></param> /// <returns></returns> public static bool CrossPlaneBox(this BoundingBoxXYZ box1, BoundingBoxXYZ box2) { if (box1 is null) { throw new ArgumentNullException(nameof(box1)); } if (box2 is null) { throw new ArgumentNullException(nameof(box2)); } box1 = box1.GetRoundBox(); box2 = box2.GetRoundBox(); var cp1 = (box1.Min - box2.Min).ToPlanePoint().CrossProduct((box2.Max - box2.Min).ToPlanePoint()); var cp2 = (box2.Max - box2.Min).ToPlanePoint().CrossProduct((box1.Max - box2.Min).ToPlanePoint()); var cp3 = (box2.Min - box1.Min).ToPlanePoint().CrossProduct((box1.Max - box1.Min).ToPlanePoint()); var cp4 = (box1.Max - box1.Min).ToPlanePoint().CrossProduct((box2.Max - box1.Min).ToPlanePoint()); var f1 = Math.Abs(cp1.DotProduct(cp2)) > 10e-3; var f2 = Math.Abs(cp3.DotProduct(cp4)) > 10e-3; return(f1 && f2); }
/// <summary> /// Gets the result of fast plane rejection of the box. /// </summary> /// <param name="box1"></param> /// <param name="box2"></param> /// <returns></returns> public static bool RejectPlaneBox(this BoundingBoxXYZ box1, BoundingBoxXYZ box2) { box1 = box1.GetRoundBox(); box2 = box2.GetRoundBox(); var v1 = box1.Min.X <= box2.Max.X; var v2 = box1.Max.X >= box2.Min.X; var v3 = box1.Min.Y <= box2.Max.Y; var v4 = box1.Max.Y >= box2.Min.Y; return(v1 && v2 && v3 && v4); }
/// <summary> /// Gets the result of space cross of the box. /// </summary> /// <param name="box1"></param> /// <param name="box2"></param> /// <returns></returns> public static bool CrossSpaceBox(this BoundingBoxXYZ box1, BoundingBoxXYZ box2) { box1 = box1.GetRoundBox(); box2 = box2.GetRoundBox(); var cp1 = (box1.Min - box2.Min).CrossProduct(box2.Max - box2.Min); var cp2 = (box2.Max - box2.Min).CrossProduct(box1.Max - box2.Min); var cp3 = (box2.Min - box1.Min).CrossProduct(box1.Max - box1.Min); var cp4 = (box1.Max - box1.Min).CrossProduct(box2.Max - box1.Min); return(cp1.GetDotProduct(cp2) > 0.000001 && cp3.GetDotProduct(cp4) > 0.000001); }
/// <summary> /// Gets the result of plane cross of the box. /// </summary> /// <param name="box1"></param> /// <param name="box2"></param> /// <returns></returns> public static bool CrossPlaneBox(this BoundingBoxXYZ box1, BoundingBoxXYZ box2) { box1 = box1.GetRoundBox(); box2 = box2.GetRoundBox(); var cp1 = (box1.Min - box2.Min).ToPlanePoint().CrossProduct((box2.Max - box2.Min).ToPlanePoint()); var cp2 = (box2.Max - box2.Min).ToPlanePoint().CrossProduct((box1.Max - box2.Min).ToPlanePoint()); var cp3 = (box2.Min - box1.Min).ToPlanePoint().CrossProduct((box1.Max - box1.Min).ToPlanePoint()); var cp4 = (box1.Max - box1.Min).ToPlanePoint().CrossProduct((box2.Max - box1.Min).ToPlanePoint()); var f1 = NumberUtil.Compare(cp1.GetDotProduct(cp2)) == 1; var f2 = NumberUtil.Compare(cp3.GetDotProduct(cp4)) == 1; return(f1 && f2); }
/// <summary> /// Gets the result of fast space rejection of the box. /// </summary> /// <param name="box1"></param> /// <param name="box2"></param> /// <returns></returns> public static bool RejectSpaceBox(this BoundingBoxXYZ box1, BoundingBoxXYZ box2) { box1 = box1.GetRoundBox(); box2 = box2.GetRoundBox(); var v1 = box1.Min.X <= box2.Max.X; var v2 = box1.Max.X >= box2.Min.X; var v3 = box1.Min.Y <= box2.Max.Y; var v4 = box1.Max.Y >= box2.Min.Y; var v5 = box1.Min.Z <= box2.Max.Z; var v6 = box1.Max.Z >= box2.Min.Z; return(v1 && v2 && v3 && v4 && v5 && v6); }
/// <summary> /// Gets the result of fast plane rejection of the box. /// </summary> /// <param name="box1"></param> /// <param name="box2"></param> /// <returns></returns> public static bool RejectPlaneBox(this BoundingBoxXYZ box1, BoundingBoxXYZ box2) { if (box1 == null) { throw new ArgumentNullException(nameof(box1)); } if (box2 == null) { throw new ArgumentNullException(nameof(box2)); } box1 = box1.GetRoundBox(); box2 = box2.GetRoundBox(); var v1 = box1.Min.X <= box2.Max.X; var v2 = box1.Max.X >= box2.Min.X; var v3 = box1.Min.Y <= box2.Max.Y; var v4 = box1.Max.Y >= box2.Min.Y; return(v1 && v2 && v3 && v4); }