< Summary

Class:GDX.Mathematics.Rotate
Assembly:GDX
File(s):D:/BuildAgent/work/GDX-Documentation/Projects/GDX_Development/Packages/com.dotbunny.gdx/GDX/Mathematics/Rotate.cs
Covered lines:0
Uncovered lines:7
Coverable lines:7
Total lines:38
Line coverage:0% (0 of 7)
Covered branches:0
Total branches:0
Covered methods:0
Total methods:1
Method coverage:0% (0 of 1)

Coverage History

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Towards(...)0%2100%

File(s)

D:/BuildAgent/work/GDX-Documentation/Projects/GDX_Development/Packages/com.dotbunny.gdx/GDX/Mathematics/Rotate.cs

#LineLine coverage
 1// Copyright (c) 2020-2022 dotBunny Inc.
 2// dotBunny licenses this file to you under the BSL-1.0 license.
 3// See the LICENSE file in the project root for more information.
 4
 5using System.Runtime.CompilerServices;
 6using Unity.Mathematics;
 7using UnityEngine;
 8
 9namespace GDX.Mathematics
 10{
 11    /// <summary>
 12    /// A set of functionality to extend on Unity's rotation based methods.
 13    /// </summary>
 14    [VisualScriptingCompatible(8)]
 15    public static class Rotate
 16    {
 17#if !UNITY_DOTSRUNTIME
 18        /// <summary>
 19        /// Create a quaternion based on a rotation from <paramref name="targetQuaternion"/> to <paramref name="otherQua
 20        /// </summary>
 21        /// <param name="targetQuaternion">The source <see cref="Quaternion"/>.</param>
 22        /// <param name="otherQuaternion">The destination <see cref="Quaternion"/>.</param>
 23        /// <param name="rotationRate">How fast should the rotation occur.</param>
 24        /// <param name="elapsedTime">How long has elapsed since the rotation started.</param>
 25        /// <returns>A rotational value.</returns>
 26        /// <exception cref="UnsupportedRuntimeException">Not supported on DOTS Runtime.</exception>
 27        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 28        public static Quaternion Towards(Quaternion targetQuaternion, Quaternion otherQuaternion, float rotationRate, fl
 029        {
 030            float rotatedAmount = rotationRate * elapsedTime;
 031            Quaternion rotationDelta = Quaternion.Inverse(targetQuaternion) * otherQuaternion;
 032            rotationDelta.ToAngleAxis(out float rotatedAngle, out Vector3 axis);
 033            rotatedAngle = math.min(rotatedAngle, rotatedAmount);
 034            return targetQuaternion * Quaternion.AngleAxis(rotatedAngle, axis);
 035        }
 36#endif
 37    }
 38}