SPH
Classes | Functions
Interval.h File Reference

Object representing interval of real values. More...

#include "common/Globals.h"
#include "math/MathUtils.h"
#include "objects/containers/StaticArray.h"

Go to the source code of this file.

Classes

class  Interval
 Object representing a 1D interval of real numbers. More...
 

Functions

template<typename T >
INLINEclamp (const T &v, const Interval &range)
 
template<typename T >
INLINE Pair< T > clampWithDerivative (const T &, const T &, const Interval &)
 Returns clamped values and the value of derivative. More...
 
template<>
INLINE Pair< FloatclampWithDerivative< Float > (const Float &v, const Float &dv, const Interval &range)
 

Detailed Description

Object representing interval of real values.

Author
Pavel Sevecek (sevecek at sirrah.troja.mff.cuni.cz)
Date
2016-2021

Definition in file Interval.h.

Function Documentation

◆ clamp()

template<typename T >
INLINE T clamp ( const T &  v,
const Interval range 
)

Overload of clamp method using range instead of lower and upper bound as values. Can be used by other Floats by specializing the method

Definition at line 120 of file Interval.h.

◆ clampWithDerivative()

template<typename T >
INLINE Pair<T> clampWithDerivative ( const T &  ,
const T &  ,
const Interval  
)

Returns clamped values and the value of derivative.

The function is specialized for floats, returning zero derivative if the value is outside range.

Todo:
clamp derivatives for all types? So far we don't clamp non-scalar quantities anyway ...

Definition at line 129 of file Interval.h.

◆ clampWithDerivative< Float >()

template<>
INLINE Pair<Float> clampWithDerivative< Float > ( const Float v,
const Float dv,
const Interval range 
)

Definition at line 134 of file Interval.h.