<commit_before>#include "TestFramework.h"
#include "treeface/math/quat.h"

using namespace treeface;

void TestFramework::content()
{
    {
        OK("default constructor");
        Quatf a;
        IS(a.get_x(), 0);
        IS(a.get_y(), 0);
        IS(a.get_z(), 0);
        IS(a.get_w(), 1);
    }

    {
        OK("constructor with values");
        Quatf b(1, 2, 3, 4);
        IS(b.get_x(), 1);
        IS(b.get_y(), 2);
        IS(b.get_z(), 3);
        IS(b.get_w(), 4);

        OK("inverse");
        Quatf b_inv = b;
        b.inverse();
        IS(b_inv.get_x(), -1);
        IS(b_inv.get_y(), -2);
        IS(b_inv.get_z(), -3);
        IS(b_inv.get_w(), 4);

        OK("normalize");
        float len_before = b.normalize();
        IS_EPSILON(len_before, std::sqrt(30));
        IS_EPSILON(b.length(), 1.0);
        IS(b.get_x(), 1.0f / len_before);
        IS(b.get_y(), 2.0f / len_before);
        IS(b.get_z(), 3.0f / len_before);
        IS(b.get_w(), 4.0f / len_before);
    }

    {
        OK("constructor with angle and axis");
        Quatf c(3.14159265358979323846/3, Vec4f(1, 2, 3, 4)); // the last component should be ommited
        IS_EPSILON(c.get_x(), 0.267261242 * sin(3.14159265358979323846/6));
        IS_EPSILON(c.get_y(), 0.534522484 * sin(3.14159265358979323846/6));
        IS_EPSILON(c.get_z(), 0.801783726 * sin(3.14159265358979323846/6));
        IS_EPSILON(c.get_w(), cos(3.14159265358979323846/6));

        IS_EPSILON(c.length(), 1);

        OK("get angle and axis");<commit_msg>fixed a bug on quaternion inverse test<commit_after>#include "TestFramework.h"
#include "treeface/math/quat.h"

using namespace treeface;

void TestFramework::content()
{
    {
        OK("default constructor");
        Quatf a;
        IS(a.get_x(), 0);
        IS(a.get_y(), 0);
        IS(a.get_z(), 0);
        IS(a.get_w(), 1);
    }

    {
        OK("constructor with values");
        Quatf b(1, 2, 3, 4);
        IS(b.get_x(), 1);
        IS(b.get_y(), 2);
        IS(b.get_z(), 3);
        IS(b.get_w(), 4);

        OK("inverse");
        Quatf b_inv = b;
        b_inv.inverse();
        IS(b_inv.get_x(), -1);
        IS(b_inv.get_y(), -2);
        IS(b_inv.get_z(), -3);
        IS(b_inv.get_w(), 4);

        OK("normalize");
        float len_before = b.normalize();
        IS_EPSILON(len_before, std::sqrt(30));
        IS_EPSILON(b.length(), 1.0);
        IS(b.get_x(), 1.0f / len_before);
        IS(b.get_y(), 2.0f / len_before);
        IS(b.get_z(), 3.0f / len_before);
        IS(b.get_w(), 4.0f / len_before);
    }

    {
        OK("constructor with angle and axis");
        Quatf c(3.14159265358979323846/3, Vec4f(1, 2, 3, 4)); // the last component should be ommited
        IS_EPSILON(c.get_x(), 0.267261242 * sin(3.14159265358979323846/6));
        IS_EPSILON(c.get_y(), 0.534522484 * sin(3.14159265358979323846/6));
        IS_EPSILON(c.get_z(), 0.801783726 * sin(3.14159265358979323846/6));
        IS_EPSILON(c.get_w(), cos(3.14159265358979323846/6));

        IS_EPSILON(c.length(), 1);

        OK("get angle and axis");
{'fraction_non_alphanumeric': 0.18217179902755268, 'fraction_numerical': 0.11280388978930309, 'mean_word_length': 2.1781668383110198, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4281002', 'n_tokens_mistral': 1475, 'n_tokens_neox': 1267, 'n_words': 213}