示例#1
0
        internal DSCoordinateSystem GetCSAtParameters(double u, double v)
        {
            bool uchange = DSGeometryExtension.ClipParamRange(ref u);
            bool vchange = DSGeometryExtension.ClipParamRange(ref v);
            // TO DO - throw a warning each time a condition above is satisfied.
            //throw new System.ArgumentException(string.Format(Properties.Resources.InvalidInput, "u or v parameter", "Surface.PointAtUVParameters"));

            IPointEntity pos    = SurfaceEntity.PointAtParameter(u, v);
            DSPoint      origin = pos.ToPoint(false, null);
            DSVector     xAxis  = new DSVector(SurfaceEntity.TangentAtUParameter(u, v));
            DSVector     yAxis  = new DSVector(SurfaceEntity.TangentAtVParameter(u, v));
            DSVector     zAxis  = xAxis.Cross(yAxis);

            return(DSCoordinateSystem.ByOriginVectors(origin, xAxis, yAxis, zAxis, false, true, false));
        }
示例#2
0
        /// <summary>
        /// Constructs a CoordinateSystem from an origin point, and two axis 
        /// vectors as input. The 'sheared' flag is used to determine if the 
        /// axes stay sheared or orthogonal to each other and 'normalized' flag 
        /// to normalize axes or not.
        /// </summary>
        /// <param name="origin">the origin of the CoordinateSystem to be constructed</param>
        /// <param name="xAxis">the x-axis of the CoordinateSystem to be constructed</param>
        /// <param name="yAxis">the y-axis of the CoordinateSystem to be constructed</param>
        /// <param name="isSheared">The 'sheared' flag is used to determine if the 
        /// axes stay sheared or orthogonal to each other.</param>
        /// <param name="isNormalized">'normalized' flag is used to determine if axes 
        /// should be normalized or not</param>
        /// <returns></returns>
        public static DSCoordinateSystem ByOriginVectors(DSPoint origin, DSVector xAxis, DSVector yAxis, bool isSheared, bool isNormalized)
        {
            if (xAxis == null)
                throw new System.ArgumentNullException("xAxis");
            else if (yAxis == null)
                throw new System.ArgumentNullException("yAxis");
            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");

            var zAxis = xAxis.Cross(yAxis);
            return ByOriginVectors(origin, xAxis, yAxis, zAxis, isSheared, isNormalized);
        }
示例#3
0
        internal DSCoordinateSystem GetCSAtParameters(double u, double v)
        {
            bool uchange = DSGeometryExtension.ClipParamRange(ref u);
            bool vchange = DSGeometryExtension.ClipParamRange(ref v);
            // TO DO - throw a warning each time a condition above is satisfied.
            //throw new System.ArgumentException(string.Format(Properties.Resources.InvalidInput, "u or v parameter", "Surface.PointAtUVParameters"));

            IPointEntity pos = SurfaceEntity.PointAtParameter(u, v);
            DSPoint origin = pos.ToPoint(false, null);
            DSVector xAxis = new DSVector(SurfaceEntity.TangentAtUParameter(u, v));
            DSVector yAxis = new DSVector(SurfaceEntity.TangentAtVParameter(u, v));
            DSVector zAxis = xAxis.Cross(yAxis);

            return DSCoordinateSystem.ByOriginVectors(origin, xAxis, yAxis, zAxis, false, true, false);
        }
示例#4
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;
        }