Vectors, a transformation matrix, seeded random numbers and colors.
Vectors, a transformation matrix, seeded random numbers and colors.
#include <iostream>
int main() {
const Vec2f position(3.f, 4.f);
std::cout <<
"distance to origin: " << position.
length() <<
'\n';
std::cout << "next position: " << position + velocity << '\n';
const Matrix4f transform = Matrix4f::translation(1.f, 2.f, 3.f) * Matrix4f::scale(2.f);
randomEngine().seed(42);
std::cout << "dice: " << random(1, 6) << ", chance: " << random(0.0, 1.0) << '\n';
const Colors::Color sky = Colors::Color::fromHexString("#87CEEB").value_or(Colors::Blue);
const Colors::Color dusk = Colors::lerp(sky, Colors::Orange, 0.5f);
std::cout << "dusk: " << dusk << ", hue " << dusk.toHsv().h << '\n';
return 0;
}
Fixed-size matrix of Rows x Cols elements, stored in row-major order.
Definition Matrix.hpp:19
constexpr Vector3D< T > transformPoint(const Vector3D< T > &p) const
Transforms a point, translation included.
Definition Matrix.hpp:124
RGBA colors: hex and HSV conversions, blending, interpolation and named colors.
Definition Color.hpp:11
Math helpers: constants, interpolation, random numbers, 2D and 3D vectors and matrices.
Definition Constants.hpp:5
2D vector; arithmetic operators work component-wise, with a vector or a scalar.
Definition Vector.hpp:14
constexpr auto length() const noexcept
Definition Vector.hpp:69
3D vector; arithmetic operators work component-wise, with a vector or a scalar.
Definition Vector.hpp:135