~hidravfx-dev-team/hidravfx/trunk

« back to all changes in this revision

Viewing changes to src/interpol.h

  • Committer: Laszlo.simon
  • Date: 2011-03-06 20:47:02 UTC
  • Revision ID: git-v1:6d6b3876e16b630ca1e50f5104ef12e7c2ea32b6
Distorsions added.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
Copyright (C) 2010 Laszlo Simon <laszlo.simon@gmail.com>
 
3
 
 
4
This file is part of the HidraVFX project.
 
5
 
 
6
HidraVFX is free software: you can redistribute it and/or modify
 
7
it under the terms of the GNU General Public License as published by
 
8
the Free Software Foundation, either version 3 of the License, or
 
9
(at your option) any later version.
 
10
 
 
11
HidraVFX is distributed in the hope that it will be useful,
 
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 
14
GNU General Public License for more details.
 
15
 
 
16
You should have received a copy of the GNU General Public License
 
17
along with HidraVFX. If not, see <http://www.gnu.org/licenses/>.
 
18
****************************************************************************/
 
19
 
 
20
#ifndef INTERPOL_H_
 
21
#define INTERPOL_H_
 
22
 
 
23
static inline float linear1(float x1, float x2, float u)
 
24
{
 
25
  return(x1*(1-u)+x2*u);
 
26
}
 
27
 
 
28
static inline float linear2(float x11, float x21, float x12, float x22, float u,float v)
 
29
{
 
30
  return ((1-u)*x11+u*x21)*(1-v)+v*((1-u)*x12+u*x22);
 
31
}
 
32
 
 
33
static inline float cosine1(float x1, float x2,float u)
 
34
{
 
35
  u = (1-cos(u*PI))*0.5;
 
36
  return (x1*(1-u)+x2*u);
 
37
}
 
38
 
 
39
static inline float cosine2(float x11, float x21, float x12, float x22, float u, float v)
 
40
{
 
41
  u = (1-cos(u*PI))*0.5;
 
42
  v = (1-cos(v*PI))*0.5;
 
43
  return ((x11*(1-u)+x21*u)*(1-v)+(x12*(1-u)+x22*u)*v);
 
44
}
 
45
 
 
46
static inline float cubic1(float x1, float x2, float u)
 
47
{
 
48
  u =(4/9)*pow(u,6)-(17/9)*pow(u,4)+(22/9)*sqr(u);
 
49
  return(x1*(1-u)+x2*u);
 
50
}
 
51
 
 
52
static inline float cubic2(float x11, float x21, float x12, float x22, float u, float v)
 
53
{
 
54
  u = (4/9)*pow(u,6)-(17/9)*pow(u,4)+(22/9)*sqr(u);
 
55
  v = (4/9)*pow(v,6)-(17/9)*pow(v,4)+(22/9)*sqr(v);
 
56
  return((x11*(1-u)+x21*u)*(1-v)+(x12*(1-u)+x22*u)*v);
 
57
}
 
58
 
 
59
#endif