Commit 2e4a0705 authored by Gauthier Quesnel's avatar Gauthier Quesnel
Browse files

core: enable sin in time_function model



Re-introduce the sin_time_function in kernel and GUI.
(closes: #39).
Co-authored-by: default avatarYves Nedelec <yves.nedelec@cerema.fr>
parent b4ca99c4
Pipeline #34594 passed with stage
in 1 minute and 33 seconds
......@@ -2298,12 +2298,17 @@ show_dynamics_inputs(editor& /*ed*/, flow& /*dyn*/)
static void
show_dynamics_inputs(editor& /*ed*/, time_func& dyn)
{
const char* items[] = { "time", "square" };
static const char* items[] = { "time", "square", "sin" };
ImGui::PushItemWidth(120.0f);
int item_current = dyn.default_f == &time_function ? 0 : 1;
int item_current = dyn.default_f == &time_function ? 0
: dyn.default_f == &square_time_function ? 1
: 2;
if (ImGui::Combo("function", &item_current, items, IM_ARRAYSIZE(items))) {
dyn.default_f =
item_current == 0 ? &time_function : square_time_function;
dyn.default_f = item_current == 0 ? &time_function
: item_current == 1 ? &square_time_function
: sin_time_function;
}
ImGui::PopItemWidth();
}
......
......@@ -5643,9 +5643,18 @@ using qss3_cross = abstract_cross<3>;
inline double
sin_time_function(double t) noexcept
{
const double f0 = 0.1;
const double pi = std::acos(-1);
return std::sin(2 * pi * f0 * t);
constexpr double f0 = 0.1;
#if irt_have_numbers == 1
constexpr double pi = std::numbers::pi_v<double>;
#else
// std::acos(-1) is not a constexpr in MVSC 2019
constexpr double pi = 3.141592653589793238462643383279502884;
#endif
constexpr const double mult = 2.0 * pi * f0;
return std::sin(mult * t);
}
inline double
......
......@@ -1471,7 +1471,9 @@ private:
if (!(is >> temp_1))
return false;
if (std::strcmp(temp_1, "square") == 0)
if (std::strcmp(temp_1, "sin") == 0)
dyn.default_f = &sin_time_function;
else if (std::strcmp(temp_1, "square") == 0)
dyn.default_f = &square_time_function;
else
dyn.default_f = &time_function;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment