A simple, header-only C++23 library for 3D vector mathematics.
input.mp4
- Intuitive vector arithmetic (
+,-,*,/). - Functions for dot product, cross product, magnitude, norm, lerp etc.
To use nvec3 in your project, simply include the src/vec3.hpp header file.
#include <print>
#include "vec3.hpp"
int main() {
nvec3::Vec3 v1(1.0f, 2.0f, 3.0f);
nvec3::Vec3 v2(4.0f, 5.0f, 6.0f);
// Add two vectors
nvec3::Vec3 sum = v1 + v2;
std::println("Sum: {}", sum);
// Calculate dot product
float dot_product = nvec3::dot(v1, v2);
std::println("Dot product: {}" , dot_product);
// Calculate magnitude
std::println("Magnitude: {}", v1.length());
return 0;
}To build the demo programs located in the demo/ directory.
-
Build the sphere demo:
mkdir build make sphere
The executable will be placed in the
build/directory. -
After you're done, you can clean the build directory:
make clean
This project is licensed under the MIT License. See the LICENSE file for more details.