// =====================================================================================================================
//  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_TEST_MATH_TRIGONOMETRIC_H
#define FENNEC_TEST_MATH_TRIGONOMETRIC_H
#include <fennec/math/trigonometric.h>
#include <fennec/math/ext/constants.h>

#include "../../test.h"

namespace fennec::test
{

	inline void fennec_test_math_trigonometric()
	{
		fennec_test_section("angle conversions");

		fennec_test_spacer(1);

		fennec_test_run(fennec::radians( 45.0f), fennec::quarter_pi<float>());
		fennec_test_run(fennec::radians( 90.0f), fennec::half_pi<float>());
		fennec_test_run(fennec::radians(180.0f), fennec::pi<float>());
		fennec_test_run(fennec::radians(270.0f), fennec::three_halves_pi<float>());
		fennec_test_run(fennec::radians(360.0f), fennec::two_pi<float>());

		fennec_test_spacer(1);

		fennec_test_run(fennec::degrees(fennec::quarter_pi<float>()),       45.0f);
		fennec_test_run(fennec::degrees(fennec::half_pi<float>()),          90.0f);
		fennec_test_run(fennec::degrees(fennec::pi<float>()),              180.0f);
		fennec_test_run(fennec::degrees(fennec::three_halves_pi<float>()), 270.0f);
		fennec_test_run(fennec::degrees(fennec::two_pi<float>()),          360.0f);

		fennec_test_spacer(2);



		fennec_test_section("trig functions");

		fennec_test_spacer(1);

		fennec_test_run(fennec::sin(fennec::sixth_pi<float>()), one_half<float>());
		fennec_test_run(fennec::cos(fennec::sixth_pi<float>()), sqrt_three<float>() / 2.0f);
		fennec_test_run(fennec::tan(fennec::sixth_pi<float>()), sqrt_three<float>() / 3.0f);

		fennec_test_spacer(1);

		fennec_test_run(fennec::asin(one_half<float>()),          fennec::sixth_pi<float>());
		fennec_test_run(fennec::acos(sqrt_three<float>() / 2.0f), fennec::sixth_pi<float>());
		fennec_test_run(fennec::atan(sqrt_three<float>() / 3.0f), fennec::sixth_pi<float>());


		fennec_test_spacer(2);


		fennec_test_run(fennec::sin(fennec::quarter_pi<float>()), sqrt_two<float>() / 2.0f);
		fennec_test_run(fennec::cos(fennec::quarter_pi<float>()), sqrt_two<float>() / 2.0f);
		fennec_test_run(fennec::tan(fennec::quarter_pi<float>()), 1.0f);

		fennec_test_spacer(1);

		fennec_test_run(fennec::asin(sqrt_two<float>() / 2.0f), fennec::quarter_pi<float>());
		fennec_test_run(fennec::acos(sqrt_two<float>() / 2.0f), fennec::quarter_pi<float>());
		fennec_test_run(fennec::atan(1.0f),                     fennec::quarter_pi<float>());

		fennec_test_spacer(2);



		fennec_test_section("hyperbolic functions");

		fennec_test_spacer(1);

		fennec_test_run(fennec::sinh(0.0f), 0.0f);
		fennec_test_run(fennec::cosh(0.0f), 1.0f);
		fennec_test_run(fennec::tanh(0.0f), 0.0f);

		fennec_test_spacer(1);

		fennec_test_run(fennec::asinh(0.0f), 0.0f);
		fennec_test_run(fennec::acosh(1.0f), 0.0f);
		fennec_test_run(fennec::atanh(0.0f), 0.0f);


		fennec_test_spacer(2);


		fennec_test_run(fennec::sinh(1.0f), (fennec::e<float>() - fennec::one_over_e<float>()) / 2.0f);
		fennec_test_run(fennec::cosh(1.0f), (fennec::e<float>() + fennec::one_over_e<float>()) / 2.0f);
		fennec_test_run(fennec::tanh(1.0f), ((fennec::e_raised_two<float>() - 1) / (fennec::e_raised_two<float>() + 1)));

		fennec_test_spacer(1);

		fennec_test_run(fennec::asinh((fennec::e<float>() - fennec::one_over_e<float>()) / 2.0f),                   1.0f);
		fennec_test_run(fennec::acosh((fennec::e<float>() + fennec::one_over_e<float>()) / 2.0f),                   1.0f);
		fennec_test_run(fennec::atanh(((fennec::e_raised_two<float>() - 1) / (fennec::e_raised_two<float>() + 1))), 1.0f);
	}

}

#endif // FENNEC_TEST_MATH_TRIGONOMETRIC_H
