Ejemplo n.º 1
0
        /// <summary>
        /// Determines whether the constraint is fulflled
        /// </summary>
        /// <param name="desiredRotation"></param>
        /// <param name="currentRotation"></param>
        /// <param name="rotationConstraint"></param>
        /// <returns></returns>
        private bool IsFulfilled(MQuaternion desiredRotation, MQuaternion currentRotation, MRotationConstraint rotationConstraint)
        {
            //By default return true -> It is assumed that interval is [-inv,+inv]
            if (rotationConstraint == null)
            {
                return(true);
            }

            MVector3 currentRotationEuler = MQuaternionExtensions.ToEuler(currentRotation);

            //Determine the global min and max coordinate
            MVector3 min = new MVector3(rotationConstraint.Limits.X.Min, rotationConstraint.Limits.Y.Min, rotationConstraint.Limits.Z.Min).Add(currentRotationEuler);
            MVector3 max = new MVector3(rotationConstraint.Limits.X.Max, rotationConstraint.Limits.Y.Max, rotationConstraint.Limits.Z.Max).Add(currentRotationEuler);


            return(currentRotationEuler.X >= min.X && currentRotationEuler.Y >= min.Y && currentRotationEuler.Z >= min.Z && currentRotationEuler.X <= max.X && currentRotationEuler.Y <= max.Y && currentRotationEuler.Z <= max.Z);
        }