Esempio n. 1
0
        private static ILineEntity GetPerpBisector(Point startPt, Point endPt,
                                                   IPlaneEntity planeOfCircle)
        {
            Vector dir = startPt.DirectionTo(endPt);

            dir = dir.Normalize();

            IPointEntity midPt = HostFactory.Factory.CreatePoint((startPt.X + endPt.X) / 2, (startPt.Y + endPt.Y) / 2, (startPt.Z + endPt.Z) / 2);

            //  get the perpendicular plane to plane of circle at mid point of segment[startPt, endPt]
            //
            IPlaneEntity perpPlane = HostFactory.Factory.PlaneByOriginNormal(midPt, dir.IVector);

            //  this intersection results in line perp to segment[startPt, endPt] & plane normal
            //  and happens to be the perpBisector of mentioned segment in planeOfCircle
            //
            ILineEntity perpBisector = planeOfCircle.IntersectWith(perpPlane);

            return(perpBisector);
        }
Esempio n. 2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="origin">the origin of the CoordinateSystem to be constructed</param>
        /// <param name="xPoint">a point on the X-axis</param>
        /// <param name="yPoint">a point on the Y-axis</param>
        /// <param name="isSheared">'sheared' flag determines if the axes stay sheared or be made orthogonal.</param>
        /// <param name="isNormalized">'normalized' flag determines if the axes are normalized or not.</param>
        /// <returns></returns>
        public static CoordinateSystem ByThreePoints(Point origin, Point xPoint, Point yPoint, bool isSheared, bool isNormalized)
        {
            if (origin == null)
                throw new System.ArgumentNullException("origin");
            else if (xPoint == null)
                throw new System.ArgumentNullException("xPoint");
            else if (yPoint == null)
                throw new System.ArgumentNullException("yPoint");

            var xAxis = origin.DirectionTo(xPoint);
            var yAxis = origin.DirectionTo(yPoint);
            var zAxis = xAxis.Cross(yAxis);

            var coordSys = ByOriginVectors(origin, xAxis, yAxis, zAxis, isSheared, isNormalized);
            if (null == coordSys)
                throw new System.Exception(string.Format(Properties.Resources.OperationFailed, "CoordinateSystem.ByThreePoints"));

            coordSys.XPoint = xPoint;
            coordSys.YPoint = yPoint;

            return coordSys;
        }