// =====================================================================================================================
//  fennec, a free and open source game engine
//  Copyright © 2025 - 2026  Medusa Slockbower
//
//  This program is free software: you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the Free Software Foundation, either version 3 of the License, or
//  (at your option) any later version.
//
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//
//  You should have received a copy of the GNU General Public License
//  along with this program.  If not, see <https://www.gnu.org/licenses/>.
// =====================================================================================================================

#ifndef FENNEC_MATH_EXT_TRIGONOMETRIC_H
#define FENNEC_MATH_EXT_TRIGONOMETRIC_H

#include <fennec/math/ext/quaternion.h>

namespace fennec
{

// Angle Conversions ===================================================================================================

#ifndef FENNEC_DOXYGEN
template<typename genType>
constexpr qua<genType> radians(const qua<genType>& degrees) {
	return qua<genType>(degrees * 0.01745329251994329576923690768489);
}

template<typename genType>
constexpr qua<genType> degrees(const qua<genType>& radians) {
	return qua<genType>(radians * 57.29577951308232087679815481410517);
}

// Trigonometric Functions =============================================================================================

template<typename genType>
constexpr qua<genType> sin(const qua<genType>& x) {
	return qua<genType>(
		fennec::sin(x.w),
		fennec::sin(x.x),
		fennec::sin(x.y),
		fennec::sin(x.z)
	);
}

template<typename genType>
constexpr qua<genType> cos(const qua<genType>& x) {
	return qua<genType>(
		fennec::cos(x.w),
		fennec::cos(x.x),
		fennec::cos(x.y),
		fennec::cos(x.z)
	);
}

template<typename genType>
constexpr qua<genType> tan(const qua<genType>& x) {
	return qua<genType>(
		fennec::tan(x.w),
		fennec::tan(x.x),
		fennec::tan(x.y),
		fennec::tan(x.z)
	);
}

template<typename genType>
constexpr qua<genType> asin(const qua<genType>& x) {
	return qua<genType>(
		fennec::asin(x.w),
		fennec::asin(x.x),
		fennec::asin(x.y),
		fennec::asin(x.z)
	);
}

template<typename genType>
constexpr qua<genType> acos(const qua<genType>& x) {
	return qua<genType>(
		fennec::acos(x.w),
		fennec::acos(x.x),
		fennec::acos(x.y),
		fennec::acos(x.z)
	);
}

template<typename genType>
constexpr qua<genType> atan(const qua<genType>& x) {
	return qua<genType>(
		fennec::atan(x.w),
		fennec::atan(x.x),
		fennec::atan(x.y),
		fennec::atan(x.z)
	);
}


// Hyperbolic Functions ================================================================================================

template<typename genType>
constexpr qua<genType> sinh(const qua<genType>& x) {
	return qua<genType>(
		fennec::sinh(x.w),
		fennec::sinh(x.x),
		fennec::sinh(x.y),
		fennec::sinh(x.z)
	);
}

template<typename genType>
constexpr qua<genType> cosh(const qua<genType>& x) {
	return qua<genType>(
		fennec::cosh(x.w),
		fennec::cosh(x.x),
		fennec::cosh(x.y),
		fennec::cosh(x.z)
	);
}

template<typename genType>
constexpr qua<genType> tanh(const qua<genType>& x) {
	return qua<genType>(
		fennec::tanh(x.w),
		fennec::tanh(x.x),
		fennec::tanh(x.y),
		fennec::tanh(x.z)
	);
}

template<typename genType>
constexpr qua<genType> asinh(const qua<genType>& x) {
	return qua<genType>(
		fennec::asinh(x.w),
		fennec::asinh(x.x),
		fennec::asinh(x.y),
		fennec::asinh(x.z)
	);
}

template<typename genType>
constexpr qua<genType> acosh(const qua<genType>& x) {
	return qua<genType>(
		fennec::acosh(x.w),
		fennec::acosh(x.x),
		fennec::acosh(x.y),
		fennec::acosh(x.z)
	);
}

template<typename genType>
constexpr qua<genType> atanh(const qua<genType>& x) {
	return qua<genType>(
		fennec::atanh(x.w),
		fennec::atanh(x.x),
		fennec::atanh(x.y),
		fennec::atanh(x.z)
	);
}
#endif

}

#endif // FENNEC_MATH_EXT_TRIGONOMETRIC_H
