﻿using System.Numerics;

namespace System
{
    /// <summary>
    /// Provides extension methods for common types.
    /// </summary>
    public static partial class Extensions
    {
        /// <summary>
        /// Applies a rotation on the X axis to the quaternion.
        /// </summary>
        /// <param name="quaternion">The quaternion.</param>
        /// <param name="angle">The rotation angle in radians.</param>
        /// <returns>The quaternion representing the final rotation.</returns>
        public static Quaternion RotateX(this Quaternion quaternion, float angle) => new Quaternion { X = (float)Math.Sin(angle * 0.5f), W = (float)Math.Cos(angle * 0.5f) } * quaternion;

        /// <summary>
        /// Applies a rotation on the Y axis to the quaternion.
        /// </summary>
        /// <param name="quaternion">The quaternion.</param>
        /// <param name="angle">The rotation angle in radians.</param>
        /// <returns>The quaternion representing the final rotation.</returns>
        public static Quaternion RotateY(this Quaternion quaternion, float angle) => new Quaternion { Y = (float)Math.Sin(angle * 0.5f), W = (float)Math.Cos(angle * 0.5f) } * quaternion;

        /// <summary>
        /// Applies a rotation on the Z axis to the quaternion.
        /// </summary>
        /// <param name="quaternion">The quaternion.</param>
        /// <param name="angle">The rotation angle in radians.</param>
        /// <returns>The quaternion representing the final rotation.</returns>
        public static Quaternion RotateZ(this Quaternion quaternion, float angle) => new Quaternion { Z = (float)Math.Sin(angle * 0.5f), W = (float)Math.Cos(angle * 0.5f) } * quaternion;
    }
}
