Add examples for different utilities

This commit is contained in:
2026-02-24 13:46:16 +01:00
parent bacba9e8c8
commit 04c7146e84
5 changed files with 213 additions and 8 deletions

View File

@@ -0,0 +1,27 @@
#include "math_lib.hpp"
#include <iostream>
int main() {
// --- Free functions ---
std::cout << "=== Free functions ===\n";
std::cout << "Math::sqrt(2.0) = " << Math::sqrt(2.0) << "\n";
std::cout << "Math::square(5.0) = " << Math::square(5.0) << "\n";
std::cout << "Math::cube(3.0) = " << Math::cube(3.0) << "\n";
// --- Vector2D ---
std::cout << "\n=== Vector2D ===\n";
Math::Vector2D v1(3.0, 4.0);
Math::Vector2D v2(1.0, 2.0);
std::cout << "v1.length() = " << v1.length() << "\n";
Math::Vector2D sum = v1.add(v2);
std::cout << "v1.add(v2) = (" << sum.x << ", " << sum.y << ")\n";
Math::Vector2D scaled = v1.scale(2.0);
std::cout << "v1.scale(2.0) = (" << scaled.x << ", " << scaled.y << ")\n";
std::cout << "v1.dot(v2) = " << v1.dot(v2) << "\n";
return 0;
}