CrystalSpace

Public API Reference

cstool/noise/interp.h
00001 // interp.h
00002 //
00003 // Copyright (C) 2003, 2004 Jason Bevins
00004 //
00005 // This library is free software; you can redistribute it and/or modify it
00006 // under the terms of the GNU Lesser General Public License as published by
00007 // the Free Software Foundation; either version 2.1 of the License, or (at
00008 // your option) any later version.
00009 //
00010 // This library is distributed in the hope that it will be useful, but WITHOUT
00011 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
00013 // License (COPYING.txt) for more details.
00014 //
00015 // You should have received a copy of the GNU Lesser General Public License
00016 // along with this library; if not, write to the Free Software Foundation,
00017 // Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 //
00019 // The developer's email is jlbezigvins@gmzigail.com (for great email, take
00020 // off every 'zig'.)
00021 //
00022 
00023 #ifndef NOISE_INTERP_H
00024 #define NOISE_INTERP_H
00025 
00026 namespace CS {
00027 namespace Math {
00028 namespace Noise {
00029 
00032 
00047   inline double CubicInterp (double n0, double n1, double n2, double n3,
00048     double a)
00049   {
00050           double p = (n3 - n2) - (n0 - n1);
00051           double q = (n0 - n1) - p;
00052           double r = n2 - n0;
00053           double s = n1;
00054           return p * a * a * a + q * a * a + r * a + s;
00055   }
00056 
00068   inline double LinearInterp (double n0, double n1, double a)
00069   {
00070     return ((1.0 - a) * n0) + (a * n1);
00071   }
00072 
00083   inline double SCurve3 (double a)
00084   {
00085     return (a * a * (3.0 - 2.0 * a));
00086   }
00087 
00101   inline double SCurve5 (double a)
00102   {
00103     double a3 = a * a * a;
00104     double a4 = a3 * a;
00105     double a5 = a4 * a;
00106     return (6.0 * a5) - (15.0 * a4) + (10.0 * a3);
00107   }
00108 
00109   // @}
00110 
00111 } // namespace Noise
00112 } // namespace Math
00113 } // namespace CS
00114 
00115 #endif

Generated for Crystal Space 2.0 by doxygen 1.7.6.1