Skip to content
Snippets Groups Projects
Commit a0674b01 authored by Rainer Kartmann's avatar Rainer Kartmann
Browse files

Move periodic_clamp (keep legacy header)

parent 50ab91a3
No related branches found
No related tags found
No related merge requests found
......@@ -150,7 +150,8 @@ SET(INCLUDES
math/distance/delta_angle.h
math/distance/angle_between.h
math/periodic_clamp.h
math/periodic_clamp.h # Legacy header.
math/periodic/periodic_clamp.h
math/periodic/periodic_diff.h
math/pose/align_box_orientation.h
......
......@@ -6,5 +6,6 @@
#include "math/convert.h"
#include "math/distance.h"
#include "math/normal.h"
#include "math/periodic.h"
#include "math/periodic_clamp.h"
#include "math/pose.h"
#pragma once
// This file is generated!
#include "periodic/periodic_clamp.h"
#include "periodic/periodic_diff.h"
#pragma once
#include <cmath>
#include <type_traits>
namespace simox::math
{
template<class T>
inline
std::enable_if_t<std::is_floating_point_v<T>, T>
periodic_clamp(T value, T periodLo, T periodHi)
{
const T dist = periodHi - periodLo;
return std::fmod(std::fmod(value - periodLo, dist) + dist, dist) + periodLo;
}
}
#pragma once
#include <cmath>
#include <type_traits>
namespace simox::math
{
template<class T>
inline
std::enable_if_t<std::is_floating_point_v<T>, T>
periodic_clamp(T value, T periodLo, T periodHi)
{
const T dist = periodHi - periodLo;
return std::fmod(std::fmod(value - periodLo, dist) + dist, dist) + periodLo;
}
}
// Legacy header.
#include "periodic/periodic_clamp.h"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment