47 constexpr unsigned int base03 = 0x002b36;
48 constexpr unsigned int base02 = 0x073642;
49 constexpr unsigned int base01 = 0x586e75;
50 constexpr unsigned int base00 = 0x657b83;
51 constexpr unsigned int base0 = 0x839496;
52 constexpr unsigned int base1 = 0x93a1a1;
53 constexpr unsigned int base2 = 0xeee8d5;
54 constexpr unsigned int base3 = 0xfdf6e3;
56 constexpr unsigned int yellow = 0xb58900;
57 constexpr unsigned int orange = 0xcb4b16;
58 constexpr unsigned int red = 0xdc322f;
59 constexpr unsigned int magenta = 0xd33682;
60 constexpr unsigned int violet = 0x6c71c4;
61 constexpr unsigned int blue = 0x268bd2;
62 constexpr unsigned int cyan = 0x2aa198;
63 constexpr unsigned int green = 0x859900;
101 return std::sqrt(
static_cast<double>(
x *
x +
y *
y));
113 return {
static_cast<double>(
x) / m,
static_cast<double>(
y) / m};
127 [[nodiscard]] T
dot(
const Vec2& other)
const {
128 return x * other.
x +
y * other.
y;
137 return {
x + rhs.
x,
y + rhs.
y};
146 return {
x * scalar,
y * scalar};
185inline double lerp(
double a,
double b,
double t) {
186 return a + t * (b - a);
206std::vector<T>
map(
const std::vector<T>& values,
207 std::function<T(T)> fn) {
208 std::vector<T> result;
209 result.reserve(values.size());
210 for (
const auto& v : values) {
211 result.push_back(fn(v));
228std::optional<T>
find_if(
const std::vector<T>& values,
229 std::function<
bool(
const T&)> pred) {
230 for (
const auto& v : values) {
231 if (pred(v))
return v;
268 [[nodiscard]]
const std::string&
label()
const {
return label_; }
Unit
Timer resolution units.
@ Milliseconds
Report in milliseconds.
@ Microseconds
Report in microseconds.
@ Seconds
Report in seconds.
const std::string & label() const
Get the label for this timer.
ScopedTimer(std::string label, Unit unit=Unit::Milliseconds)
Start the timer with a label.
~ScopedTimer()
Stop the timer and print elapsed time.
A 2D vector with common geometric operations.
double magnitude() const
Compute the Euclidean magnitude.
Vec2 operator*(T scalar) const
Scalar multiplication.
Vec2(T x=T{}, T y=T{})
Construct a new Vec2.
T dot(const Vec2 &other) const
Compute the dot product of two vectors.
Vec2< double > normalized() const
Return a normalized (unit-length) copy of this vector.
Vec2 operator+(const Vec2 &rhs) const
Vector addition.
Color palette constants from the Solarized scheme.
constexpr unsigned int base02
Dark background.
constexpr unsigned int base01
Optional emphasized content.
constexpr unsigned int base2
Light background highlights.
constexpr unsigned int magenta
Accent: magenta.
constexpr unsigned int green
Accent: green.
constexpr unsigned int red
Accent: red.
constexpr unsigned int blue
Accent: blue.
constexpr unsigned int base03
Darkest background.
constexpr unsigned int base0
Body text (light mode)
constexpr unsigned int base00
Body text (dark mode)
constexpr unsigned int violet
Accent: violet.
constexpr unsigned int yellow
Accent: yellow.
constexpr unsigned int base1
Optional de-emphasized content.
constexpr unsigned int cyan
Accent: cyan.
constexpr unsigned int base3
Lightest background.
constexpr unsigned int orange
Accent: orange.
The Yoda namespace — core utilities for the doxyYoda demo.
Vec2< double > Vec2d
Convenience alias for a double-precision 2D vector.
Vec2< int > Vec2i
Convenience alias for an integer 2D vector.
Interpolation
Interpolation methods available for smoothing operations.
@ Linear
Simple linear interpolation: .
@ Cosine
Cosine-smoothed interpolation.
@ Cubic
Cubic Hermite interpolation.
@ CatmullRom
Catmull-Rom spline interpolation.
std::optional< T > find_if(const std::vector< T > &values, std::function< bool(const T &)> pred)
Find the first element satisfying a predicate.
double lerp(double a, double b, double t)
Linearly interpolate between two values.
std::vector< T > map(const std::vector< T > &values, std::function< T(T)> fn)
Apply a function element-wise to a vector of values.