add wobbling in a cone as model
This commit is contained in:
parent
e6331749b2
commit
ee195c313c
37
src/motions/conewobble.cpp
Normal file
37
src/motions/conewobble.cpp
Normal file
@ -0,0 +1,37 @@
|
||||
|
||||
#include "conewobble.h"
|
||||
#include "coordinates.h"
|
||||
|
||||
#include <random>
|
||||
#include <string>
|
||||
|
||||
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<std::string, double> ¶meters) {
|
||||
BaseMotion::setParameters(parameters);
|
||||
m_angle = parameters.at("angle");
|
||||
}
|
||||
|
||||
std::unordered_map<std::string, double> 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);
|
||||
}
|
||||
}
|
30
src/motions/conewobble.h
Normal file
30
src/motions/conewobble.h
Normal file
@ -0,0 +1,30 @@
|
||||
#ifndef CONEWOBBLE_H
|
||||
#define CONEWOBBLE_H
|
||||
|
||||
#include "base.h"
|
||||
#include "coordinates.h"
|
||||
|
||||
#include <random>
|
||||
|
||||
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<std::string, double> &) override;
|
||||
|
||||
[[nodiscard]] std::unordered_map<std::string, double> getParameters() const override;
|
||||
|
||||
[[nodiscard]] std::string toString() const override;
|
||||
|
||||
private:
|
||||
double m_angle{0};
|
||||
coordinates::SphericalPos m_axis{1, 0};
|
||||
};
|
||||
}
|
||||
#endif //CONEWOBBLE_H
|
Loading…
Reference in New Issue
Block a user