<commit_before>#include "../test.h"
#include "../../src/math/obb.h"

TEST(Test_Obb, CreationFromPoints)
{
  Eigen::MatrixXf points = Eigen::MatrixXf::Zero(3, 8);
  points.col(0) = Eigen::Vector3f(-1, -1, -1);
  points.col(1) = Eigen::Vector3f(-1, 1, 1);
  points.col(2) = Eigen::Vector3f(1, -1, 1);
  points.col(3) = Eigen::Vector3f(1, 1, -1);
  points.col(4) = Eigen::Vector3f(1, 1, 1);
  points.col(5) = Eigen::Vector3f(-1, -1, 1);
  points.col(6) = Eigen::Vector3f(1, -1, -1);
  points.col(7) = Eigen::Vector3f(-1, 1, -1);

  Math::Obb obb(points);

  EXPECT_Vector3f_NEAR(Eigen::Vector3f(0, 0, 0), obb.getCenter(), 1E-4);
  EXPECT_Vector3f_NEAR(Eigen::Vector3f(1, 1, 1), obb.getHalfWidths(), 1E-4);

  EXPECT_Vector3f_NEAR(Eigen::Vector3f(-1, -1, -1), obb.corners[0], 1E-4);
  EXPECT_Vector3f_NEAR(Eigen::Vector3f(-1, -1, 1), obb.corners[1], 1E-4);
  EXPECT_Vector3f_NEAR(Eigen::Vector3f(1, -1, 1), obb.corners[2], 1E-4);
  EXPECT_Vector3f_NEAR(Eigen::Vector3f(1, -1, -1), obb.corners[3], 1E-4);
  EXPECT_Vector3f_NEAR(Eigen::Vector3f(-1, 1, -1), obb.corners[4], 1E-4);
  EXPECT_Vector3f_NEAR(Eigen::Vector3f(-1, 1, 1), obb.corners[5], 1E-4);
  EXPECT_Vector3f_NEAR(Eigen::Vector3f(1, 1, 1), obb.corners[6], 1E-4);
  EXPECT_Vector3f_NEAR(Eigen::Vector3f(1, 1, -1), obb.corners[7], 1E-4);
}
<commit_msg>Test remaining constructors of Obb.<commit_after>#include "../test.h"
#include "../../src/math/obb.h"

TEST(Test_Obb, CreationWithDefaultConstructor)
{
  Math::Obb obb;

  EXPECT_FALSE(obb.isInitialized());
}

TEST(Test_Obb, CreationFromPoints)
{
  Eigen::MatrixXf points = Eigen::MatrixXf::Zero(3, 8);
  points.col(0) = Eigen::Vector3f(-1, -1, -1);
  points.col(1) = Eigen::Vector3f(-1, 1, 1);
  points.col(2) = Eigen::Vector3f(1, -1, 1);
  points.col(3) = Eigen::Vector3f(1, 1, -1);
  points.col(4) = Eigen::Vector3f(1, 1, 1);
  points.col(5) = Eigen::Vector3f(-1, -1, 1);
  points.col(6) = Eigen::Vector3f(1, -1, -1);
  points.col(7) = Eigen::Vector3f(-1, 1, -1);

  Math::Obb obb(points);

  EXPECT_TRUE(obb.isInitialized());

  EXPECT_Vector3f_NEAR(Eigen::Vector3f(0, 0, 0), obb.getCenter(), 1E-4);
  EXPECT_Vector3f_NEAR(Eigen::Vector3f(1, 1, 1), obb.getHalfWidths(), 1E-4);

  EXPECT_Vector3f_NEAR(Eigen::Vector3f(-1, -1, -1), obb.corners[0], 1E-4);
  EXPECT_Vector3f_NEAR(Eigen::Vector3f(-1, -1, 1), obb.corners[1], 1E-4);
  EXPECT_Vector3f_NEAR(Eigen::Vector3f(1, -1, 1), obb.corners[2], 1E-4);
  EXPECT_Vector3f_NEAR(Eigen::Vector3f(1, -1, -1), obb.corners[3], 1E-4);
  EXPECT_Vector3f_NEAR(Eigen::Vector3f(-1, 1, -1), obb.corners[4], 1E-4);
  EXPECT_Vector3f_NEAR(Eigen::Vector3f(-1, 1, 1), obb.corners[5], 1E-4);
  EXPECT_Vector3f_NEAR(Eigen::Vector3f(1, 1, 1), obb.corners[6], 1E-4);
  EXPECT_Vector3f_NEAR(Eigen::Vector3f(1, 1, -1), obb.corners[7], 1E-4);
}

TEST(Test_Obb, CreationFromCenterHalfWidthsAndAxes)
{
  Eigen::Vector3f center(1, 2, 3);
  Eigen::Vector3f halfWidths(0.1f, 0.2f, 0.3f);
  Eigen::Matrix3f axes;
  axes << 0, 0, 1, 0, 1, 0, 1, 0, 0;
  Math::Obb obb(center, halfWidths, axes);

  EXPECT_TRUE(obb.isInitialized());

  EXPECT_Vector3f_NEAR(center, obb.getCenter(), 1E-4);
  EXPECT_Vector3f_NEAR(halfWidths, obb.getHalfWidths(), 1E-4);

  EXPECT_Vector3f_NEAR(Eigen::Vector3f(0.7f, 1.8f, 2.9f), obb.corners[0], 1E-4);
  EXPECT_Vector3f_NEAR(Eigen::Vector3f(0.7f, 1.8f, 3.1f), obb.corners[1], 1E-4);
  EXPECT_Vector3f_NEAR(Eigen::Vector3f(1.3f, 1.8f, 3.1f), obb.corners[2], 1E-4);
  EXPECT_Vector3f_NEAR(Eigen::Vector3f(1.3f, 1.8f, 2.9f), obb.corners[3], 1E-4);
  EXPECT_Vector3f_NEAR(Eigen::Vector3f(0.7f, 2.2f, 2.9f), obb.corners[4], 1E-4);
  EXPECT_Vector3f_NEAR(Eigen::Vector3f(0.7f, 2.2f, 3.1f), obb.corners[5], 1E-4);
  EXPECT_Vector3f_NEAR(Eigen::Vector3f(1.3f, 2.2f, 3.1f), obb.corners[6], 1E-4);
  EXPECT_Vector3f_NEAR(Eigen::Vector3f(1.3f, 2.2f, 2.9f), obb.corners[7], 1E-4);
}


{'fraction_non_alphanumeric': 0.2199582027168234, 'fraction_numerical': 0.09273772204806688, 'mean_word_length': 5.236156351791531, 'pattern_counts': {'":': 0, '<': 5, '<?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': '5410349', 'n_tokens_mistral': 2029, 'n_tokens_neox': 1899, 'n_words': 271}