<commit_before>#pragma once
//=====================================================================//
/*!	@file
	@brief	Quaternion (四元数)クラス（ヘッダー）
	@author	平松邦仁 (<EMAIL>)
*/
//=====================================================================//
#include <vector>
#include <utility>
#include "utils/vtx.hpp"
#include "utils/mtx.hpp"

namespace qtx {

	//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
	/*!
		@brief	quaternion (四元数)テンプレート・クラス
	*/
	//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
	template <typename T>
	class quaternion {
	public:
		T		x;
		T		y;
		T		z;
		T		w;

		typedef T	value_type;

		//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
		/*!
			@brief	quaternion コンストラクター
		*/
		//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
		inline quaternion() : x(0), y(0), z(0), w(1) { }


		//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
		/*!
			@brief	quaternion コンストラクター
			@param[in]	xx	X	要素
			@param[in]	yy	Y	要素
			@param[in]	zz	Z	要素
			@param[in]	ww	w	要素
		*/
		//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
		inline quaternion(T xx, T yy, T zz, T ww = static_cast<T>(1)) : x(xx), y(yy), z(zz), w(ww) { }

		//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
		/*!
			@brief	quaternion 要素を設定
			@param[in]	xx	X	要素
			@param[in]	yy	Y	要素
			@param[in]	zz	Z	要素
			@param[in]	ww	w	要素
		*/
		//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
		inline void set(T xx, T yy, T zz, T ww = static_cast<T>(1)) { x = xx; y = yy; z = zz; w = ww; }


		//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
		/*!
			@brief	normalise @n
			normalising a quaternion works similar to a vector. This method will
			not do anything
			if the quaternion is close enough to being unit-length.
			define TOLERANCE as something small like 0.00001f to get accurate results
		*/
		//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
		void normalise() {
			T TOLERANCE = static_cast<T>(0.000001);
			// Don't normalize if we don't have to
			T mag2 = w * w + x * x + y * y + z * z;
			if(std::abs(mag2) > TOLERANCE && fabs(mag2 - static_cast<T>(1)) > TOLERANCE) {
				T mag = std::sqrt(mag2);
				w /= mag;
				x /= mag;
				y /= mag;
				z /= mag;
			}
		}


// We need to get the inverse of a quaternion to properly apply a quaternion-rotation to a vector
// The conjugate of a quaternion is the same as the inverse, as long as the quaternion is unit-length
		quaternion get_conjugate() const {
			return std::move(quaternion(-x, -y, -z, w));
		}


		//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
		/*!
			@brief	quaternion 掛け算
			@param[in]	left	左辺
			@param[in]	right	右辺
		*/
		//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
		void mult(const quaternion& left, const quaternion& right) {
			T d1, d2, d3, d4;
			d1 =  left.w * right.w;
			d2 = -left.x * right.x;
			d3 = -left.y * right.y;
			d4 = -left.z * right.z;
			T ww = d1 + d2 + d3 + d4;

			d1 =   left.w * right.x;
			d2 =  right.w *  left.x;
			d3 =   left.y * right.z;
			d4 =  -left.z * right.y;
			T xx =  d1 + d2 + d3 + d4;

			d1 =   left.w * right.y;
			d2 =  right.w *  left.y;
			d3 =   left.z * right.x;
			d4 =  -left.x * right.z;<commit_msg>Update comment<commit_after>#pragma once
//=====================================================================//
/*!	@file
	@brief	Quaternion (四元数)クラス（ヘッダー）
	@author	平松邦仁 (<EMAIL>)
*/
//=====================================================================//
#include <vector>
#include <utility>
#include "utils/vtx.hpp"
#include "utils/mtx.hpp"

namespace qtx {

	//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
	/*!
		@brief	quaternion (四元数)テンプレート・クラス
	*/
	//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
	template <typename T>
	class quaternion {
	public:
		T		x;
		T		y;
		T		z;
		T		w;

		typedef T	value_type;

		//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
		/*!
			@brief	quaternion コンストラクター
		*/
		//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
		inline quaternion() : x(0), y(0), z(0), w(1) { }


		//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
		/*!
			@brief	quaternion コンストラクター
			@param[in]	xx	X	要素
			@param[in]	yy	Y	要素
			@param[in]	zz	Z	要素
			@param[in]	ww	w	要素
		*/
		//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
		inline quaternion(T xx, T yy, T zz, T ww = static_cast<T>(1)) : x(xx), y(yy), z(zz), w(ww) { }

		//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
		/*!
			@brief	quaternion 要素を設定
			@param[in]	xx	X	要素
			@param[in]	yy	Y	要素
			@param[in]	zz	Z	要素
			@param[in]	ww	w	要素
		*/
		//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
		inline void set(T xx, T yy, T zz, T ww = static_cast<T>(1)) { x = xx; y = yy; z = zz; w = ww; }


		//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
		/*!
			@brief	normalise @n
			normalising a quaternion works similar to a vector. This method will
			not do anything
			if the quaternion is close enough to being unit-length.
			define TOLERANCE as something small like 0.00001f to get accurate results
		*/
		//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
		void normalise() {
			T TOLERANCE = static_cast<T>(0.000001);
			// Don't normalize if we don't have to
			T mag2 = w * w + x * x + y * y + z * z;
			if(std::abs(mag2) > TOLERANCE && fabs(mag2 - static_cast<T>(1)) > TOLERANCE) {
				T mag = std::sqrt(mag2);
				w /= mag;
				x /= mag;
				y /= mag;
				z /= mag;
			}
		}


		//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
		/*!
			@brief	We need to get the inverse of a quaternion to properly
					apply a quaternion-rotation to a vector
					The conjugate of a quaternion is the same as the inverse,
					as long as the quaternion is unit-length
			@return 答え
		*/
		//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
		quaternion get_conjugate() const {
			return std::move(quaternion(-x, -y, -z, w));
		}


		//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
		/*!
			@brief	quaternion 掛け算
			@param[in]	left	左辺
			@param[in]	right	右辺
		*/
		//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//
		void mult(const quaternion& left, const quaternion& right) {
			T d1, d2, d3, d4;
			d1 =  left.w * right.w;
			d2 = -left.x * right.x;
			d3 = -left.y * right.y;
			d4 = -left.z * right.z;
			T ww = d1 + d2 + d3 + d4;

			d1 =   left.w * right.x;
			d2 =  right.w *  left.x;
			d3 =   left.y * right.z;
			d4 =  -left.z * right.y;
			T xx =  d1 + d2 + d3 + d4;

			d1 =   left.w * right.y;
			d2 =  right.w *  left.y;
			d3 =   left.z * right.x;
			d4 =  -left.x * right.z;
{'fraction_non_alphanumeric': 0.41204956558894745, 'fraction_numerical': 0.013673265916536106, 'mean_word_length': 3.3560794044665014, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '948056', 'n_tokens_mistral': 3132, 'n_tokens_neox': 2545, 'n_words': 615}