コード例 #1
0
ファイル: CheckGeometry.cs プロジェクト: taihuynh116/KT_Addin
        /// <summary>
        /// Lấy điểm chiếu của một điểm lên đường thẳng
        /// </summary>
        /// <param name="line">Đường thẳng đang xét</param>
        /// <param name="point">Điểm đang xét</param>
        /// <returns></returns>
        public static XYZ GetProjectPoint(Curve line, XYZ point)
        {
            if (IsPointInLineOrExtend(CheckGeometry.ConvertLine(line), point))
            {
                return(point);
            }
            XYZ   vecL = GeomUtil.SubXYZ(line.GetEndPoint(1), line.GetEndPoint(0));
            XYZ   vecP = GeomUtil.SubXYZ(point, line.GetEndPoint(0));
            Plane p    = Plane.CreateByOriginAndBasis(line.GetEndPoint(0), GeomUtil.UnitVector(vecL), GeomUtil.UnitVector(GeomUtil.CrossMatrix(vecL, vecP)));

            return(GetProjectPoint(p, point));
        }
コード例 #2
0
ファイル: GeomUtil.cs プロジェクト: taihuynh116/KT_Addin
        public static double GetAngle2(XYZ targetVec, XYZ vecX, XYZ vecY, XYZ vecZ)
        {
            vecX = vecX.Normalize(); vecY = vecY.Normalize(); vecZ = vecZ.Normalize();
            if (!IsEqual(vecX.DotProduct(vecY), 0))
            {
                throw new Exception("Two basis X and Y is not perpecular!");
            }
            if (!IsEqual(vecX.CrossProduct(vecY), vecZ))
            {
                throw new Exception("Three basises are not a coordiante!");
            }
            Plane pl    = Plane.CreateByOriginAndBasis(XYZ.Zero, vecX, vecY);
            XYZ   pjPnt = CheckGeometry.GetProjectPoint(pl, targetVec);

            return(GetAngle(targetVec, pjPnt, vecZ));
        }