Esempio n. 1
0
        /// <summary>
        /// Constructor that does the same as CoordinateSystem.AtParameter but that it checks if the z-axis is
        /// in the same general direction as the given upVector. If not, it flips the z-axis to make it point 
        /// in the same overall direction as the upVector and also flips the y-axis accordingly to preserve 
        /// the right-handed CoordinateSystem rule.
        /// </summary>
        /// <param name="contextCurve"></param>
        /// <param name="t"></param>
        /// <param name="upVector"></param>
        /// <returns></returns>
        public static DSCoordinateSystem AtParameter(DSCurve contextCurve, double t, DSVector upVector)
        {
            if (contextCurve == null)
                throw new System.ArgumentNullException("contextCurve");
            else if (upVector == null)
                throw new System.ArgumentNullException("upVector");
            else if (upVector.IsZeroVector())
                throw new System.ArgumentException(string.Format(Properties.Resources.IsZeroVector, "up vector"), "upVector");

            var cs = contextCurve.CoordinateSystemAtParameterCore(t, upVector);
            if (null == cs)
                throw new System.Exception(string.Format(Properties.Resources.OperationFailed, "DSCoordinateSystem.AtParameter"));

            //  property assigments
            //
            cs.ContextCurve = contextCurve;
            cs.T = t;
            cs.Distance = contextCurve.DistanceAtParameter(t);
            cs.UpVector = upVector;

            return cs;
        }
Esempio n. 2
0
        /// <summary>
        /// Constructs a a CoordinateSystem with its origin at the given parameter on the given curve. Its x-axis is tangential to the curve, 
        /// y-axis is along the normal and z-axis is along bi-normal at that point. This method is complementary to the 
        /// CoordinateSystemAtParameterAlongCurve() method in Curve class and has consistent behavior.
        /// </summary>
        /// <param name="contextCurve"></param>
        /// <param name="t"></param>
        /// <returns></returns>
        public static DSCoordinateSystem AtParameter(DSCurve contextCurve, double t)
        {
            if (contextCurve == null)
                throw new System.ArgumentNullException("contextCurve");

            var cs = contextCurve.CoordinateSystemAtParameterCore(t, null);
            if (null == cs)
                throw new System.Exception(string.Format(Properties.Resources.OperationFailed, "DSCoordinateSystem.AtParameter"));

            cs.ContextCurve = contextCurve;
            cs.T = t;
            cs.Distance = contextCurve.DistanceAtParameter(t);

            return cs;
        }