Google

Main Page   Class Hierarchy   Compound List   File List   Compound Members  

bezier.h

00001 /*
00002     Copyright (C) 1998 by Ayal Zwi Pinkus
00003 
00004     This library is free software; you can redistribute it and/or
00005     modify it under the terms of the GNU Library General Public
00006     License as published by the Free Software Foundation; either
00007     version 2 of the License, or (at your option) any later version.
00008 
00009     This library is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012     Library General Public License for more details.
00013 
00014     You should have received a copy of the GNU Library General Public
00015     License along with this library; if not, write to the Free
00016     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00017 */
00018 
00019 #ifndef __CS_BEZIER_H__
00020 #define __CS_BEZIER_H__
00021 
00024 // Cache interface
00027 #define NR1 4
00028 #define NR2 9
00029 #define NR3 16
00030 #define NR4 25
00031 #define NR5 36
00032 #define NR6 49
00033 #define NR7 64
00034 #define NR8 81
00035 #define NR9 100
00036 
00037 #define IND1  0
00038 #define IND2  (IND1+NR1)
00039 #define IND3  (IND2+NR2)
00040 #define IND4  (IND3+NR3)
00041 #define IND5  (IND4+NR4)
00042 #define IND6  (IND5+NR5)
00043 #define IND7  (IND6+NR6)
00044 #define IND8  (IND7+NR7)
00045 #define IND9  (IND8+NR8)
00046 #define IND10 (IND9+NR9)
00047 
00048 #define OFFSET_1  (IND1  * 9)
00049 #define OFFSET_2  (IND2  * 9)
00050 #define OFFSET_3  (IND3  * 9)
00051 #define OFFSET_4  (IND4  * 9)
00052 #define OFFSET_5  (IND5  * 9)
00053 #define OFFSET_6  (IND6  * 9)
00054 #define OFFSET_7  (IND7  * 9)
00055 #define OFFSET_8  (IND8  * 9)
00056 #define OFFSET_9  (IND9  * 9)
00057 #define OFFSET_10 (IND10 * 9)
00058 
00059 #define LUT_SIZE  OFFSET_10 // Doubles
00060 
00061 class csVector3;
00062 class csVector2;
00063 
00064 class csBezier2
00065 {
00066 private:
00067 
00068   // binary coefficients for a 2nd degree polynomial
00069   static double bincoeff[3];
00070 
00071   // This should be approx. less than 82K
00072   static double bernsteinMap[LUT_SIZE];
00073   static double bernsteinDuMap[LUT_SIZE];
00074   static double bernsteinDvMap[LUT_SIZE];
00075   static bool initialized;
00076 
00077 public:
00078 
00080   static void Initialize ();
00081 
00083   static double BernsteinAt(double u, int j, double v, int k);
00084 
00089   static double BernsteinDuAt(double u, int j, double v, int k);
00090 
00095   static double BernsteinDvAt(double u, int j, double v, int k);
00096 
00105   static csVector3 GetNormal(double** aControls, int u,
00106                              int v, int resolution);
00107 
00112   static csVector3 GetNormal(double** aControls, double u, double v);
00113 
00119   static csVector3 GetPoint(double** aControls, int u, int v, int resolution,
00120                             double *map = NULL);
00121 
00127   static csVector2 GetTextureCoord(double** aControls, int u, int v,
00128                                    int resolution, double *map = NULL);
00129 
00134   static csVector3 GetPoint(double** aControls, double u, double v,
00135                             double (*func)(double, int, double, int) = NULL );
00136 };
00137 
00138 #endif // __CS_BEZIER_H__

Generated for Crystal Space by doxygen 1.2.5 written by Dimitri van Heesch, ©1997-2000