ETL
0.04.19
Main Page
Related Pages
Classes
Files
File List
File Members
ETL
_curve_func.h
Go to the documentation of this file.
1
25
/* === S T A R T =========================================================== */
26
27
#ifndef __ETL__CURVE_FUNC_H
28
#define __ETL__CURVE_FUNC_H
29
30
/* === H E A D E R S ======================================================= */
31
32
#include <functional>
33
#include "
_fixed.h
"
34
35
/* -- C L A S S E S --------------------------------------------------------- */
36
37
template
<
class
T,
class
K=
float
>
38
struct
affine_combo
39
{
40
// from (a) to (x) : x = a(1-t) + b(t)
41
T
operator()
(
const
T &a,
const
T &b,
const
K &t)
const
42
{
43
return
T( (b-a)*t+a );
44
}
45
46
// from (x) to (a) : a = (x-b(t)) / (1-t)
47
T
reverse
(
const
T &x,
const
T &b,
const
K &t)
const
48
{
49
return
T( (x-t*b)*(static_cast<K>(1)/(static_cast<K>(1)-t)) );
50
}
51
};
52
53
template
<
class
T,
class
K=
float
>
54
struct
distance_func
:
public
std::binary_function<T, T, K>
55
{
56
K
operator()
(
const
T &a,
const
T &b)
const
57
{
58
T delta=b-a;
59
return
static_cast<
K
>
(delta*delta);
60
}
61
62
K
cook
(
const
K &x)
const
{
return
x*x; }
63
K
uncook
(
const
K &x)
const
{
return
sqrt
(x); }
64
65
};
66
67
/* -- E N D ----------------------------------------------------------------- */
68
69
#endif
Generated on Mon Nov 16 2015 15:32:02 for ETL by
1.8.1.2