Example #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Joint" /> class.
        /// </summary>
        /// <param name="isGround">if set to <c>true</c> [is ground].</param>
        /// <param name="jointType">Type of the joint.</param>
        /// <param name="currentJointPosition">The current joint position.</param>
        /// <param name="specifiedAs">The specified as.</param>
        /// <exception cref="System.Exception">Values for x and y must be provided for joint.</exception>
        internal Joint(bool isGround, JointType jointType, double[] currentJointPosition = null,
                       JointSpecifiedAs specifiedAs = JointSpecifiedAs.Design)
        {
            IsGround         = isGround;
            TypeOfJoint      = jointType;
            jointSpecifiedAs = specifiedAs;

            if (currentJointPosition == null)
            {
                return;
            }
            if (currentJointPosition.GetLength(0) < 2)
            {
                throw new Exception("Values for x and y must be provided for joint.");
            }
            x = xInitial = xLast = xNumerical = currentJointPosition[0];
            y = yInitial = yLast = yNumerical = currentJointPosition[1];
            if (currentJointPosition.GetLength(0) >= 3 && jointType != JointType.R)
            {
                OffsetSlideAngle = currentJointPosition[2];
            }
            else if (jointType == JointType.P || jointType == JointType.RP)
            {
                OffsetSlideAngle = 0.0;
            }

            while (OffsetSlideAngle > Math.PI / 2)
            {
                OffsetSlideAngle -= Math.PI;
            }
            while (OffsetSlideAngle < -Math.PI / 2)
            {
                OffsetSlideAngle += Math.PI;
            }
        }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Joint" /> class.
        /// </summary>
        /// <param name="isGround">if set to <c>true</c> [is ground].</param>
        /// <param name="jointType">Type of the joint.</param>
        /// <param name="currentJointPosition">The current joint position.</param>
        /// <param name="specifiedAs">The specified as.</param>
        /// <exception cref="System.Exception">Values for x and y must be provided for joint.</exception>
        internal Joint(bool isGround, JointType jointType, double[] currentJointPosition = null,
                       JointSpecifiedAs specifiedAs = JointSpecifiedAs.Design)
        {
            IsGround         = isGround;
            TypeOfJoint      = jointType;
            JointSpecifiedAs = specifiedAs;

            if (currentJointPosition == null)
            {
                return;
            }
            if (currentJointPosition.GetLength(0) < 2)
            {
                throw new Exception("Values for x and y must be provided for joint.");
            }
            X = XInitial = XLast = XNumerical = currentJointPosition[0];
            Y = YInitial = YLast = YNumerical = currentJointPosition[1];
            if (currentJointPosition.GetLength(0) >= 3 && jointType != JointType.R)
            {
                OffsetSlideAngle = currentJointPosition[2];
            }
            else if (jointType == JointType.P || jointType == JointType.RP)
            {
                OffsetSlideAngle = 0.0;
            }

            while (OffsetSlideAngle > Constants.QuarterCircle)
            {
                OffsetSlideAngle -= Math.PI;
            }
            while (OffsetSlideAngle < -Constants.QuarterCircle)
            {
                OffsetSlideAngle += Math.PI;
            }
        }