From: Alexander Schmidt Date: Wed, 20 Jul 2016 20:55:20 +0000 (+0200) Subject: Pass wind speed and magic constant via sea constructor X-Git-Url: http://git.treefish.org/~alex/seamulator.git/commitdiff_plain/721ef20fdcc8171b0cdcf7ee3402a0fb6eb37f46 Pass wind speed and magic constant via sea constructor --- diff --git a/include/sea.h b/include/sea.h index 798b92d..01f8c92 100644 --- a/include/sea.h +++ b/include/sea.h @@ -13,19 +13,19 @@ class Sea { public: - Sea(WaterSurfacePtr surface); + Sea(WaterSurfacePtr surface, double windSpeed, double magicConstant); ~Sea(); Sea(const Sea&) = delete; Sea& operator=(const Sea&) = delete; void update(); private: - static const double PHILLIPS_CONSTANT; static const double GRAVITATIONAL_CONSTANT; WaterSurfacePtr m_surface; double m_windDirection[2]; double m_windSpeed; + double m_magicConstant; std::random_device m_randomDevice; std::mt19937 m_randomGenerator; std::normal_distribution<> m_normalDistribution; diff --git a/src/sea.cpp b/src/sea.cpp index 85191d4..597e0a1 100644 --- a/src/sea.cpp +++ b/src/sea.cpp @@ -6,13 +6,13 @@ #include "watersurface.h" -const double Sea::PHILLIPS_CONSTANT{0.0000001}; const double Sea::GRAVITATIONAL_CONSTANT{9.8}; -Sea::Sea(WaterSurfacePtr surface) : +Sea::Sea(WaterSurfacePtr surface, double windSpeed, double magicConstant) : m_surface{surface}, m_windDirection{1, 0}, - m_windSpeed{10}, + m_windSpeed{windSpeed}, + m_magicConstant{magicConstant}, m_randomGenerator{m_randomDevice()}, m_normalDistribution{0.0, 1.0} { @@ -89,7 +89,7 @@ double Sea::phillipsSpectrum(double k_x, double k_y) const const double cosineFactor = pow((k_x / k) * m_windDirection[0] + (k_y / k) * m_windDirection[1], 2); - return PHILLIPS_CONSTANT * exp(-1 / pow(k * L, 2)) / pow(k, 4) * + return m_magicConstant * exp(-1 / pow(k * L, 2)) / pow(k, 4) * cosineFactor; } diff --git a/src/seamulator.cpp b/src/seamulator.cpp index c5f7936..92dfac6 100644 --- a/src/seamulator.cpp +++ b/src/seamulator.cpp @@ -33,7 +33,7 @@ int main(int argc, char** argv) std::srand(std::time(0)); surface = std::make_shared(LATTICE_SIZE, LATTICE_EXTEND); - sea = std::make_shared(surface); + sea = std::make_shared(surface, 10, 0.0000001); seaView = std::make_unique(INIT_VIEW_DISTANCE, INIT_VIEW_AZIMUTH, INIT_VIEW_ALTITUDE);