コード例 #1
0
        /// <summary>
        /// Gets the point and the line about space direction relationship.
        /// </summary>
        /// <param name="pt"></param>
        /// <param name="line"></param>
        /// <returns></returns>
        public static GeometryPosition GetSpacePosition(this XYZ pt, Line line)
        {
            var pt1 = line.GetEndPoint(0);
            var pt2 = line.GetEndPoint(1);

            // Distance Arithmetic: If a point in a line, it meets sum of the distance from the point to each endpoint equal the line length.
            var k = pt1.DistanceTo(pt) + pt2.DistanceTo(pt) - pt2.DistanceTo(pt1);

            return(NumberUtil.Compare(k) == -1 ? GeometryPosition.Inner : GeometryPosition.Other);
        }
コード例 #2
0
        /// <summary>
        /// Gets the result of whether the line line1 and the line line2 is plane parallel.
        /// </summary>
        /// <param name="line1"></param>
        /// <param name="line2"></param>
        /// <returns></returns>
        public static bool IsPlaneParallel(this Line line1, Line line2)
        {
            var p1 = line1.GetEndPoint(0);
            var p2 = line1.GetEndPoint(1);
            var p3 = line2.GetEndPoint(0);
            var p4 = line2.GetEndPoint(1);

            line1 = Line.CreateBound(new XYZ(p1.X, p1.Y, 0), new XYZ(p2.X, p2.Y, 0));
            line2 = Line.CreateBound(new XYZ(p3.X, p3.Y, 0), new XYZ(p4.X, p4.Y, 0));

            return(NumberUtil.Compare(Math.Sin(line1.Direction.AngleTo(line2.Direction))) == 0);
        }
コード例 #3
0
        /// <summary>
        /// Gets the result of space cross of the box.
        /// </summary>
        /// <param name="doc"></param>
        /// <param name="elm1"></param>
        /// <param name="elm2"></param>
        /// <returns></returns>
        public static bool CrossSpaceBox(this Document doc, Element elm1, Element elm2)
        {
            var box1 = elm1.GetRoundBox(doc);
            var box2 = elm2.GetRoundBox(doc);
            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);
            var f1   = NumberUtil.Compare(cp1.GetDotProduct(cp2)) == 1;
            var f2   = NumberUtil.Compare(cp3.GetDotProduct(cp4)) == 1;

            return(f1 && f2);
        }
コード例 #4
0
        /// <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);
        }
コード例 #5
0
 /// <summary>
 /// Gets the result of whether the line line1 and the line line2 is space parallel.
 /// </summary>
 /// <param name="line1"></param>
 /// <param name="line2"></param>
 /// <returns></returns>
 public static bool IsSpaceParallel(this Line line1, Line line2)
 {
     return(NumberUtil.Compare(Math.Sin(line1.Direction.AngleTo(line2.Direction))) == 0);
 }