zenilib  0.5.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
lib3ds_math.c
Go to the documentation of this file.
1 /*
2  Copyright (C) 1996-2008 by Jan Eric Kyprianidis <www.kyprianidis.com>
3  All rights reserved.
4 
5  This program is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published
7  by the Free Software Foundation, either version 2.1 of the License, or
8  (at your option) any later version.
9 
10  Thisprogram is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with this program; If not, see <http://www.gnu.org/licenses/>.
17 */
18 #include "lib3ds_impl.h"
19 
20 
21 float
22 lib3ds_math_ease(float fp, float fc, float fn, float ease_from, float ease_to) {
23  double s, step;
24  double tofrom;
25  double a;
26 
27  s = step = (float)(fc - fp) / (fn - fp);
28  tofrom = ease_to + ease_from;
29  if (tofrom != 0.0) {
30  if (tofrom > 1.0) {
31  ease_to = (float)(ease_to / tofrom);
32  ease_from = (float)(ease_from / tofrom);
33  }
34  a = 1.0 / (2.0 - (ease_to + ease_from));
35 
36  if (step < ease_from) s = a / ease_from * step * step;
37  else {
38  if ((1.0 - ease_to) <= step) {
39  step = 1.0 - step;
40  s = 1.0 - a / ease_to * step * step;
41  } else {
42  s = ((2.0 * step) - ease_from) * a;
43  }
44  }
45  }
46  return((float)s);
47 }
48 
49 
50 void
51 lib3ds_math_cubic_interp(float *v, float *a, float *p, float *q, float *b, int n, float t) {
52  float x, y, z, w;
53  int i;
54 
55  x = 2 * t * t * t - 3 * t * t + 1;
56  y = -2 * t * t * t + 3 * t * t;
57  z = t * t * t - 2 * t * t + t;
58  w = t * t * t - t * t;
59  for (i = 0; i < n; ++i) {
60  v[i] = x * a[i] + y * b[i] + z * p[i] + w * q[i];
61  }
62 }
LIB3DSAPI void lib3ds_math_cubic_interp(float *v, float *a, float *p, float *q, float *b, int n, float t)
Definition: lib3ds_math.c:51
GLdouble s
Definition: glew.h:1376
LIB3DSAPI float lib3ds_math_ease(float fp, float fc, float fn, float ease_from, float ease_to)
Definition: lib3ds_math.c:22
GLclampd n
Definition: glew.h:7287
EGLSurface EGLint x
Definition: eglext.h:293
GLdouble GLdouble t
Definition: glew.h:1384
GLboolean GLboolean GLboolean GLboolean a
Definition: glew.h:8736
const GLdouble * v
Definition: glew.h:1377
GLfloat GLfloat p
Definition: glew.h:14938
EGLSurface EGLint EGLint y
Definition: eglext.h:293
GLdouble GLdouble GLdouble GLdouble q
Definition: glew.h:1400
GLdouble GLdouble GLdouble b
Definition: glew.h:8383
GLint GLint GLint GLint z
Definition: gl2ext.h:1214
GLint GLint GLint GLint GLint w
Definition: gl2ext.h:1215
int i
Definition: pngrutil.c:1377