10 #ifndef VSR_INTERP_INCLUDED
11 #define VSR_INTERP_INCLUDED
33 static T cubic(T _a, T _b, T _c, T _d,
double t);
36 static T quadric(T _a, T _b, T _c,
double t);
39 static T linear(T _a, T _b,
double t);
42 static T sqlinear(T _a, T _b,
double t);
45 static T linear( T * s,
int num,
double t);
49 static T quadric(T * s,
int num,
double t,
bool closed =0);
53 static T cubic(T * s,
int num,
double t);
59 static T surface(T *s,
double u,
double v);
68 static T surface(T a, T b, T c, T d,
double u,
double v);
71 static T sqsurface(T a, T b, T c, T d,
double u,
double v);
76 static T volume( T a, T b, T c, T d, T e, T f, T g, T h,
double u,
double v,
double w);
79 static T volume(T *s,
double x,
double y,
double z);
90 inline T Interp :: cubic(T _a, T _b, T _c, T _d,
double t) {
118 inline T Interp :: quadric(T _a, T _b, T _c,
double t) {
122 double nt = -1.0 + 2.0*t;
128 T a = ( ( (_a + _c) * .5 ) - _b ) * p;
129 T b = (_c - _a ) * (.5 * nt);
136 inline T Interp :: linear(T _a, T _b,
double t) {
137 return _a * (1-t) + _b * (t);
140 inline T Interp :: sqlinear(T _a, T _b,
double t) {
141 return _a * ((1-t)*(1-t)) + _b * (t*t);
145 inline T Interp :: linear(T * s,
int num,
double t) {
146 double fw = t * (num-1);
150 if (iw == num-1) { iw = num-2; rw = 1.0; }
152 return s[iw] * (1.0 - rw) + s[iw+1] * rw;
156 inline T Interp :: quadric( T * cp,
int num,
double t,
bool closed ) {
162 double n = closed ? num / 2.0 : (num-1)/2.0;
167 double td = ( t * n );
174 if ( (rem != 0) && (it==fn) ) {
175 return closed? linear( cp[gt], cp[0], ct *2 ) : linear( cp[gt], cp[gt+1], ct *2 );
178 return closed ? quadric(cp[gt], cp[gt+1], (it==fn-1)? cp[0] : cp[gt+2], ct) : quadric(cp[gt], cp[gt+1], cp[gt+2], ct);
186 inline T Interp :: surface(T * cp,
double u,
double v){
187 T bot = cp[0] * (1-u) + cp[1] * u;
188 T top = cp[2] * (1-u) + cp[3] * u;
189 return bot * (1-v) + top * v;
193 inline T Interp :: surface(T a, T b, T c, T d,
double u,
double v){
194 T bot = a * (1-u) + b * u;
195 T top = d * (1-u) + c * u;
196 return bot * (1-v) + top * v;
200 inline T Interp :: sqsurface(T a, T b, T c, T d,
double u,
double v){
201 T bot = a * ( (1-u) * (1-u) ) + b * (u*u);
202 T top = d * ( (1-u)* (1-u) ) + c * (u*u);
203 return bot * ( (1-v) * (1-v) ) + top * (v*v);
226 inline T Interp :: volume(T * cp,
double u,
double v,
double w){
227 T fbottom = cp[0] * (1-u) + cp[4] * u;
228 T ftop = cp[2] * (1-u) + cp[6] * u;
229 T fmid = fbottom * (1-v) + ftop * (v);
231 T bbottom = cp[1] * (1-u) + cp[5] * u;
232 T btop = cp[3] * (1-u) + cp[7] * u;
233 T bmid = bbottom * (1-v) + btop * (v);
235 return fmid * (1-w) + bmid * w;
239 inline T Interp :: volume( T a, T b, T c, T d, T e, T f, T g, T h,
double u,
double v,
double w){
240 T front = surface(a, b, c, d, u, v);
241 T back = surface(e, f, g, h, u, v);
243 return linear(front, back, w);
Definition: vsr_interp.h:27
the versor library namespace
Definition: vsr_algebra.h:29