C++/raylib semi-realistic fantasy/sci-fi planet generator on a fixed icosphere grid (Eulerian: properties flow over fixed cells). World-creation stages: tectonics, continental drift & erosion, hydrology (rivers/lakes), climate (temperature + orographic precipitation), and biome classification. Engine in src/sim (raylib-free, headless-testable), viewer in src/render. See CLAUDE.md and docs/ (design-notes.md, fauna-flora-plan.md = next step). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
31 lines
926 B
C++
31 lines
926 B
C++
#pragma once
|
|
#include <cmath>
|
|
|
|
// Simple 3D vector for planet geometry (metric, double precision).
|
|
struct Vec3 {
|
|
double x = 0.0, y = 0.0, z = 0.0;
|
|
|
|
Vec3() = default;
|
|
Vec3(double x_, double y_, double z_) : x(x_), y(y_), z(z_) {}
|
|
|
|
Vec3 operator+(const Vec3& o) const { return {x + o.x, y + o.y, z + o.z}; }
|
|
Vec3 operator-(const Vec3& o) const { return {x - o.x, y - o.y, z - o.z}; }
|
|
Vec3 operator*(double s) const { return {x * s, y * s, z * s}; }
|
|
|
|
double dot(const Vec3& o) const { return x * o.x + y * o.y + z * o.z; }
|
|
|
|
Vec3 cross(const Vec3& o) const {
|
|
return {y * o.z - z * o.y,
|
|
z * o.x - x * o.z,
|
|
x * o.y - y * o.x};
|
|
}
|
|
|
|
double length() const { return std::sqrt(x * x + y * y + z * z); }
|
|
|
|
Vec3 normalized() const {
|
|
double l = length();
|
|
if (l <= 1e-300) return {0, 0, 0};
|
|
return {x / l, y / l, z / l};
|
|
}
|
|
};
|