/// <summary>
        /// Gets the rotation of a point along the line at the specified length
        /// </summary>
        /// <param name="normalizedLength"></param>
        /// <param name="rotationType"></param>
        /// <returns></returns>
        public Quaternion GetRotation(float normalizedLength, RotationTypeEnum rotationType = RotationTypeEnum.None)
        {
            rotationType = (rotationType != RotationTypeEnum.None) ? rotationType : RotationType;
            Vector3 rotationVector = Vector3.zero;

            switch (rotationType)
            {
            case RotationTypeEnum.None:
            default:
                break;

            case RotationTypeEnum.Velocity:
                rotationVector = GetVelocity(normalizedLength);
                break;

            case RotationTypeEnum.RelativeToOrigin:
                Vector3 point  = GetPoint(normalizedLength);
                Vector3 origin = transform.TransformPoint(OriginOffset);
                rotationVector = (point - origin).normalized;
                break;
            }

            if (rotationVector.magnitude < MinRotationMagnitude)
            {
                return(transform.rotation);
            }

            Vector3 upVector = GetUpVectorInternal(normalizedLength);

            if (ManualUpVectorBlend > 0f)
            {
                Vector3 manualUpVector = LineUtils.GetVectorCollectionBlend(ManualUpVectors, normalizedLength, Loops);
                upVector = Vector3.Lerp(upVector, manualUpVector, manualUpVector.magnitude);
            }

            if (FlipUpVector)
            {
                upVector = -upVector;
            }

            return(Quaternion.LookRotation(rotationVector, upVector));
        }
Beispiel #2
0
        /// <summary>
        /// Разворачиваем изображение, если оно не горизонтально
        /// </summary>
        /// <param name="lang">Искомый язык</param>
        /// <param name="nextPage">Исходное изображение</param>
        /// <returns>Полученное изображение</returns>
        IImage FindOrientation(ILanguage lang, IImage nextPage)
        {
            //
            RotationTypeEnum rotateTo = imageTools.DetectOrientationByText(nextPage, lang);

            if (rotateTo != RotationTypeEnum.RT_NoRotation)
            {
                if (rotateTo == RotationTypeEnum.RT_Counterclockwise)
                {
                    rotateTo = RotationTypeEnum.RT_Clockwise;
                }
                else if (rotateTo == RotationTypeEnum.RT_Clockwise)
                {
                    rotateTo = RotationTypeEnum.RT_Counterclockwise;
                }

                nextPage = imageTools.RotateImageByRotationType(nextPage, rotateTo);

                _isOrientationChanged = true;
            }

            return(nextPage);
        }
 /// <summary>
 /// Gets the rotation of a point along the line at the specified index
 /// </summary>
 /// <param name="pointIndex"></param>
 /// <param name="rotationType"></param>
 /// <returns></returns>
 public Quaternion GetRotation(int pointIndex, RotationTypeEnum rotationType = RotationTypeEnum.None)
 {
     return(GetRotation((float)pointIndex / NumPoints, (rotationType != RotationTypeEnum.None) ? rotationType : RotationType));
 }