flatten 20260225
This commit is contained in:
24
tjp/core/math/clamp.hpp
Executable file
24
tjp/core/math/clamp.hpp
Executable file
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// Math.hpp
|
||||
// amoeba
|
||||
//
|
||||
// Created by Timothy Prepscius on 12/30/16.
|
||||
// Copyright © 2016 Timothy Prepscius. All rights reserved.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace tjp::core::math {
|
||||
|
||||
template<typename V, typename L, typename R>
|
||||
inline V clamp(const V &v, const L &l, const R &r)
|
||||
{
|
||||
if (v < l)
|
||||
return (V)l;
|
||||
if (v > r)
|
||||
return (V)r;
|
||||
return v;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user