C:/jkyprian/devel/lib3ds/lib3ds/ease.c

00001 /*
00002  * The 3D Studio File Format Library
00003  * Copyright (C) 1996-2007 by Jan Eric Kyprianidis <www.kyprianidis.com>
00004  * All rights reserved.
00005  *
00006  * This program is  free  software;  you can redistribute it and/or modify it
00007  * under the terms of the  GNU Lesser General Public License  as published by 
00008  * the  Free Software Foundation;  either version 2.1 of the License,  or (at 
00009  * your option) any later version.
00010  *
00011  * This  program  is  distributed in  the  hope that it will  be useful,  but
00012  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
00013  * or  FITNESS FOR A  PARTICULAR PURPOSE.  See the  GNU Lesser General Public  
00014  * License for more details.
00015  *
00016  * You should  have received  a copy of the GNU Lesser General Public License
00017  * along with  this program;  if not, write to the  Free Software Foundation,
00018  * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019  *
00020  * $Id: ease.c,v 1.6 2007/06/15 09:33:19 jeh Exp $
00021  */
00022 #include <lib3ds/ease.h>
00023 
00024 
00033 Lib3dsFloat
00034 lib3ds_ease(Lib3dsFloat fp, Lib3dsFloat fc, Lib3dsFloat fn,
00035   Lib3dsFloat ease_from, Lib3dsFloat ease_to)
00036 {
00037   Lib3dsDouble s,step;
00038   Lib3dsDouble tofrom;
00039   Lib3dsDouble a;
00040 
00041   s=step=(Lib3dsFloat)(fc-fp)/(fn-fp);
00042   tofrom=ease_to+ease_from;
00043   if (tofrom!=0.0) {
00044     if (tofrom>1.0) {
00045       ease_to=(Lib3dsFloat)(ease_to/tofrom);
00046       ease_from=(Lib3dsFloat)(ease_from/tofrom);
00047     }
00048     a=1.0/(2.0-(ease_to+ease_from));
00049 
00050     if (step<ease_from) s=a/ease_from*step*step;
00051     else {
00052       if ((1.0-ease_to)<=step) {
00053         step=1.0-step;
00054         s=1.0-a/ease_to*step*step;
00055       }
00056       else {
00057         s=((2.0*step)-ease_from)*a;
00058       }
00059     }
00060   }
00061   return((Lib3dsFloat)s);
00062 }

Hosted by
SourceForge.net Logo
Generated at Wed Jun 20 18:51:36 2007 by Doxygen 1.5.2