From ee195c313cc8e7ede6f4c30bfb409a0449f03911 Mon Sep 17 00:00:00 2001 From: Dominik Demuth Date: Fri, 13 Dec 2024 14:04:30 +0100 Subject: [PATCH] add wobbling in a cone as model --- src/motions/conewobble.cpp | 37 +++++++++++++++++++++++++++++++++++++ src/motions/conewobble.h | 30 ++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 src/motions/conewobble.cpp create mode 100644 src/motions/conewobble.h diff --git a/src/motions/conewobble.cpp b/src/motions/conewobble.cpp new file mode 100644 index 0000000..75fe8fa --- /dev/null +++ b/src/motions/conewobble.cpp @@ -0,0 +1,37 @@ + +#include "conewobble.h" +#include "coordinates.h" + +#include +#include + +namespace motions { + WobbleCone::WobbleCone(const double delta, const double eta, const double chi, std::mt19937_64 &rng) : BaseMotion("Wobble in Cone", delta, eta, rng), m_angle(chi) {} + WobbleCone::WobbleCone(std::mt19937_64 &rng) : BaseMotion("Wobble in Cone", rng) {} + + void WobbleCone::initialize() { + m_axis = draw_position(); + } + + double WobbleCone::jump() { + const double real_angle = m_uni_dist(m_rng) * m_angle; + const double phi = 2 * M_PI * m_uni_dist(m_rng); + return omega_q(coordinates::rotate(m_axis, real_angle, phi)); + } + + void WobbleCone::setParameters(const std::unordered_map ¶meters) { + BaseMotion::setParameters(parameters); + m_angle = parameters.at("angle"); + } + + std::unordered_map WobbleCone::getParameters() const { + auto parameter = BaseMotion::getParameters(); + parameter["angle"] = m_angle; + + return parameter; + } + + std::string WobbleCone::toString() const { + return std::string("ConeWobble/angle=") + std::to_string(m_angle); + } +} \ No newline at end of file diff --git a/src/motions/conewobble.h b/src/motions/conewobble.h new file mode 100644 index 0000000..65f5ec5 --- /dev/null +++ b/src/motions/conewobble.h @@ -0,0 +1,30 @@ +#ifndef CONEWOBBLE_H +#define CONEWOBBLE_H + +#include "base.h" +#include "coordinates.h" + +#include + +namespace motions { + class WobbleCone: public BaseMotion { + public: + WobbleCone(double, double, double, std::mt19937_64&); + explicit WobbleCone(std::mt19937_64&); + + void initialize() override; + + double jump() override; + + void setParameters(const std::unordered_map &) override; + + [[nodiscard]] std::unordered_map getParameters() const override; + + [[nodiscard]] std::string toString() const override; + + private: + double m_angle{0}; + coordinates::SphericalPos m_axis{1, 0}; + }; +} +#endif //CONEWOBBLE_H