remove tau loop
This commit is contained in:
@ -2,11 +2,14 @@
|
||||
// Created by dominik on 8/12/24.
|
||||
//
|
||||
|
||||
#include <cmath>
|
||||
// #include <cmath>
|
||||
#include <random>
|
||||
#include <cmath>
|
||||
#include <utility>
|
||||
|
||||
#include "base.h"
|
||||
|
||||
|
||||
Motion::Motion(const double delta, const double eta, std::mt19937_64& rng) : m_delta(delta), m_eta(eta), m_rng(rng) {
|
||||
m_uni_dist = std::uniform_real_distribution(0., 1.);
|
||||
}
|
||||
@ -19,13 +22,13 @@ double Motion::omega_q(const double cos_theta, const double phi) const {
|
||||
const double cos_theta_square = cos_theta * cos_theta;
|
||||
const double sin_theta_square = 1. - cos_theta_square;
|
||||
|
||||
return M_PI * m_delta * (3 * cos_theta_square - 1 - m_eta * sin_theta_square * cos(2.*phi));
|
||||
return M_PI * m_delta * (3 * cos_theta_square - 1 - m_eta * sin_theta_square * std::cos(2.*phi));
|
||||
}
|
||||
|
||||
double Motion::draw_position() {
|
||||
std::pair<double, double> Motion::draw_position() {
|
||||
const double cos_theta = 1 - 2 * m_uni_dist(m_rng);
|
||||
const double phi = 2.0 * M_PI * m_uni_dist(m_rng);
|
||||
|
||||
return omega_q(cos_theta, phi);
|
||||
return std::make_pair(cos_theta, phi);
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
|
||||
#include <random>
|
||||
#include <utility>
|
||||
|
||||
class Motion {
|
||||
public:
|
||||
@ -15,9 +16,10 @@ public:
|
||||
Motion(double, double, std::mt19937_64&);
|
||||
explicit Motion(std::mt19937_64&);
|
||||
|
||||
double draw_position();
|
||||
std::pair<double, double> draw_position();
|
||||
[[nodiscard]] double omega_q(double, double) const;
|
||||
|
||||
virtual void initialize() = 0;
|
||||
virtual double jump() = 0;
|
||||
|
||||
[[nodiscard]] double getDelta() const { return m_delta; }
|
||||
@ -25,11 +27,11 @@ public:
|
||||
[[nodiscard]] double getEta() const { return m_eta; }
|
||||
void setEta(const double eta) { m_eta = eta; }
|
||||
|
||||
private:
|
||||
protected:
|
||||
double m_delta{1.};
|
||||
double m_eta{0.};
|
||||
std::mt19937_64& m_rng;
|
||||
std::uniform_real_distribution<double> m_uni_dist;
|
||||
std::uniform_real_distribution<> m_uni_dist;
|
||||
};
|
||||
|
||||
#endif //RWSIM_MOTIONBASE_H
|
||||
|
@ -9,6 +9,9 @@ RandomJump::RandomJump(const double delta, const double eta, std::mt19937_64 &rn
|
||||
|
||||
RandomJump::RandomJump(std::mt19937_64 &rng) : Motion(rng) {}
|
||||
|
||||
void RandomJump::initialize() {}
|
||||
|
||||
double RandomJump::jump() {
|
||||
return draw_position();
|
||||
const auto [cos_theta, phi] = draw_position();
|
||||
return omega_q(cos_theta, phi);
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ public:
|
||||
RandomJump(double, double, std::mt19937_64&);
|
||||
explicit RandomJump(std::mt19937_64&);
|
||||
|
||||
void initialize() override;
|
||||
double jump() override;
|
||||
};
|
||||
|
||||
|
@ -9,6 +9,46 @@ TetrahedralJump::TetrahedralJump(const double delta, const double eta, std::mt19
|
||||
|
||||
TetrahedralJump::TetrahedralJump(std::mt19937_64& rng) : Motion(rng) {}
|
||||
|
||||
double TetrahedralJump::jump() {
|
||||
return draw_position();
|
||||
void TetrahedralJump::initialize() {
|
||||
// const auto [cos_theta, phi] = draw_position();
|
||||
//
|
||||
// m_corners[0] = omega_q(cos_theta, phi);
|
||||
//
|
||||
// const double alpha = 2. * M_PI * m_uni_dist(m_rng);
|
||||
// std::cout << alpha << std::endl;
|
||||
|
||||
// v1[0] = sin(phi0)*sin(teta0);
|
||||
// v2[0] = cos(phi0)*sin(teta0);
|
||||
// v3[0] = cos(teta0);
|
||||
//
|
||||
// abs = v1[0]*v1[0]+v2[0]*v2[0]+v3[0]*v3[0]; // Normalization
|
||||
// v1[0] = v1[0]/abs;
|
||||
// v2[0] = v2[0]/abs;
|
||||
// v3[0] = v3[0]/abs;
|
||||
//
|
||||
// /*Calculating the components of the other orientationts. Compare Master Thesis M. Sattig,corrected Version (Share/Abschlussarbeiten)*/
|
||||
// norm = sqrt(1 - v3[0]*v3[0])+1E-12;
|
||||
// normI = 1.0/(norm);
|
||||
//
|
||||
// cosgama = cos(delta0);
|
||||
// singama = sin(delta0);
|
||||
// v1[1] = v1[0]*cosBETA + sinBETA*normI*(-v1[0]*v3[0]*singama - v2[0]*cosgama);
|
||||
// v2[1] = v2[0]*cosBETA + sinBETA*normI*(-v2[0]*v3[0]*singama + v1[0]*cosgama);
|
||||
// v3[1] = v3[0]*cosBETA + sinBETA*norm*singama;
|
||||
//
|
||||
// cosgama = cos(gama + delta0);
|
||||
// singama = sin(gama + delta0);
|
||||
// v1[2] = v1[0]*cosBETA + sinBETA*normI*(-v1[0]*v3[0]*singama - v2[0]*cosgama);
|
||||
// v2[2] = v2[0]*cosBETA + sinBETA*normI*(-v2[0]*v3[0]*singama + v1[0]*cosgama);
|
||||
// v3[2] = v3[0]*cosBETA + sinBETA*norm*singama;
|
||||
//
|
||||
// cosgama = cos(2.0*gama + delta0);
|
||||
// singama = sin(2.0*gama + delta0);
|
||||
// v1[3] = v1[0]*cosBETA + sinBETA*normI*(-v1[0]*v3[0]*singama - v2[0]*cosgama);
|
||||
// v2[3] = v2[0]*cosBETA + sinBETA*normI*(-v2[0]*v3[0]*singama + v1[0]*cosgama);
|
||||
// v3[3] = v3[0]*cosBETA + sinBETA*norm*singama;
|
||||
}
|
||||
|
||||
double TetrahedralJump::jump() {
|
||||
return 0.;
|
||||
}
|
||||
|
@ -7,13 +7,20 @@
|
||||
|
||||
#include "base.h"
|
||||
#include <random>
|
||||
#include <cmath>
|
||||
#include <array>
|
||||
|
||||
class TetrahedralJump final : public Motion {
|
||||
public:
|
||||
TetrahedralJump(double, double, std::mt19937_64&);
|
||||
explicit TetrahedralJump(std::mt19937_64&);
|
||||
|
||||
void initialize() override;
|
||||
double jump() override;
|
||||
|
||||
private:
|
||||
const double m_beta{std::acos(-1/3.)};
|
||||
std::array<double, 4> m_corners{};
|
||||
};
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user