Ejemplo n.º 1
0
        /// <summary>
        /// Constructors a point by projecting a point on a plane with given project direction.
        /// </summary>
        /// <param name="contextPlane">Plane of projection</param>
        /// <param name="direction">Projection direction</param>
        /// <returns>Point</returns>
        public DSPoint Project(DSPlane contextPlane, DSVector direction)
        {
            if (contextPlane == null)
            {
                throw new ArgumentNullException("contextPlane");
            }
            else if (direction == null)
            {
                throw new ArgumentNullException("direction");
            }
            else if (direction.IsZeroVector())
            {
                throw new ArgumentException(string.Format(Properties.Resources.IsZeroVector, "direction"));
            }
            else if (direction.IsPerpendicular(contextPlane.Normal))
            {
                throw new ArgumentException(string.Format(Properties.Resources.IsParallel, "contextPlane", "direction", "DSPoint.Project"));
            }

            var pt = contextPlane.Project(this, direction);

            pt.Context        = contextPlane;
            pt.ReferencePoint = this;
            pt.Direction      = direction;
            pt.Persist();
            return(pt);
        }
Ejemplo n.º 2
0
        internal static DSCoordinateSystem ByOriginVectors(DSPoint origin, DSVector xAxis, DSVector yAxis, DSVector zAxis,
            bool isSheared, bool isNormalized, bool visible)
        {
            if (origin == null)
                throw new System.ArgumentNullException("origin");
            else if (xAxis == null)
                throw new System.ArgumentNullException("xAxis");
            else if (yAxis == null)
                throw new System.ArgumentNullException("yAxis");
            else if (zAxis == null)
                throw new System.ArgumentNullException("zAxis");
            else if (xAxis.IsZeroVector())
                throw new System.ArgumentException(string.Format(Properties.Resources.IsZeroVector, "x axis"), "xAxis");
            else if (yAxis.IsZeroVector())
                throw new System.ArgumentException(string.Format(Properties.Resources.IsZeroVector, "y axis"), "yAxis");
            else if (zAxis.IsZeroVector())
                throw new System.ArgumentException(string.Format(Properties.Resources.IsZeroVector, "z axis"), "zAxis");
            else if (xAxis.IsParallel(yAxis))
                throw new System.ArgumentException(string.Format(Properties.Resources.IsParallel, "x axis", "y axis", "DSCoordinateSystem.ByOriginVectors"), "xAxis, yAxis");
            else if (!isSheared && (!xAxis.IsPerpendicular(yAxis) || !yAxis.IsPerpendicular(zAxis) || !zAxis.IsPerpendicular(xAxis)))
            {
                //  this is not the case for sheared but axes are not orthogonal
                //
                zAxis = xAxis.Cross(yAxis);
                yAxis = zAxis.Cross(xAxis);
            }

            if (isNormalized)
            {
                xAxis = xAxis.Normalize();
                yAxis = yAxis.Normalize();
                zAxis = zAxis.Normalize();
            }

            var cs = HostFactory.Factory.CoordinateSystemByData(null); //create identity matrix
            if (null == cs)
                throw new System.Exception(string.Format(Properties.Resources.OperationFailed, "DSCoordinateSystem.ByOriginVectors"));

            cs.Set(origin.PointEntity, xAxis.IVector, yAxis.IVector, zAxis.IVector);
            var coordSys = new DSCoordinateSystem(cs, visible);

            return coordSys;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Returns the projection of the curve on the plane with given direction
        /// Argument Requirement:
        /// direction.Length > 0
        /// </summary>
        /// <param name="contextPlane">Projection plane</param>
        /// <param name="direction">Projection direction</param>
        /// <returns>Projected curve on the context plane</returns>
        public DSCurve Project(DSPlane contextPlane, DSVector direction)
        {
            string kMethodName = "DSCurve.Project";
            if (null == contextPlane)
                throw new System.ArgumentNullException("contextPlane");
            else if (null == direction)
                throw new System.ArgumentNullException("direction");
            if (direction.Length.EqualsTo(0.0))
                throw new System.ArgumentException(string.Format(Properties.Resources.IsZero, "length of the direction vector"), "direction");
            if (direction.IsPerpendicular(contextPlane.Normal))
                return null;

            ICurveEntity entity = CurveEntity.ProjectOn(contextPlane.PlaneEntity, direction.IVector);
            if (null == entity)
                throw new System.InvalidOperationException(string.Format(Properties.Resources.OperationFailed, kMethodName));

            return entity.ToCurve(true, this);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Constructors a point by projecting a point on a plane with given project direction.
        /// </summary>
        /// <param name="contextPlane">Plane of projection</param>
        /// <param name="direction">Projection direction</param>
        /// <returns>Point</returns>
        public DSPoint Project(DSPlane contextPlane, DSVector direction)
        {
            if (contextPlane == null)
            {
                throw new ArgumentNullException("contextPlane");
            }
            else if (direction == null)
            {
                throw new ArgumentNullException("direction");
            }
            else if (direction.IsZeroVector())
            {
                throw new ArgumentException(string.Format(Properties.Resources.IsZeroVector, "direction"));
            }
            else if (direction.IsPerpendicular(contextPlane.Normal))
            {
                throw new ArgumentException(string.Format(Properties.Resources.IsParallel, "contextPlane", "direction", "DSPoint.Project"));
            }

            var pt = contextPlane.Project(this, direction);
            pt.Context = contextPlane;
            pt.ReferencePoint = this;
            pt.Direction = direction;
            pt.Persist();
            return pt;
        }