added box

This commit is contained in:
2025-04-18 00:43:46 +03:00
parent baf7ee8f88
commit 492ddfd566
7 changed files with 55 additions and 3 deletions

View File

@@ -0,0 +1 @@
target_sources(omath PRIVATE box.cpp)

View File

@@ -0,0 +1,32 @@
//
// Created by Vlad on 4/18/2025.
//
#include "omath/3d_primitives/box.hpp"
namespace omath::primitives
{
std::array<Vector3<float>, 8> CreateBox(const Vector3<float>& top, const Vector3<float>& bottom,
const Vector3<float>& dirForward,
const Vector3<float>& dirRight)
{
const auto height = top.DistTo(bottom);
const auto sideSize = height / 6.f;
std::array<Vector3<float>, 8> points;
points[0] = bottom + (dirForward + dirRight) * sideSize;
points[1] = bottom + (dirForward - dirRight) * sideSize;
points[2] = bottom + (-dirForward + dirRight) * sideSize;
points[3] = bottom + (-dirForward - dirRight) * sideSize;
points[4] = top + (dirForward + dirRight) * sideSize;
points[5] = top + (dirForward - dirRight) * sideSize;
points[6] = top + (-dirForward + dirRight) * sideSize;
points[7] = top + (-dirForward - dirRight) * sideSize;
return points;
}
}

View File

@@ -7,4 +7,5 @@ add_subdirectory(projectile_prediction)
add_subdirectory(pathfinding)
add_subdirectory(projection)
add_subdirectory(collision)
add_subdirectory(engines)
add_subdirectory(engines)
add_subdirectory(3d_primitives)