Caution
I am not responsible for the use of my projects for bad purposes.
#include <iostream>
#include <iomanip>
#include <cmath>
#include <chrono>
#include <thread>
int main() {
constexpr double g = 9.81;
constexpr double L = 1.0;
constexpr double damping = 0.05;
constexpr double dt = 0.01;
constexpr int steps = 1500;
double theta = M_PI / 4;
double omega = 0.0;
std::cout << std::fixed << std::setprecision(4);
for (int i = 0; i < steps; ++i) {
double alpha = - (g / L) * std::sin(theta) - damping * omega;
omega += alpha * dt;
theta += omega * dt;
double x = L * std::sin(theta);
std::cout << "[θ]: " << theta << " rad\t| ";
std::cout << "[x]: " << x << " m\n";
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
}