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 
00076 public:
00077 
00079   csBezier2();
00080 
00082   static double BernsteinAt(double u, int j, double v, int k);
00083 
00088   static double BernsteinDuAt(double u, int j, double v, int k);
00089 
00094   static double BernsteinDvAt(double u, int j, double v, int k);
00095 
00104   static csVector3 GetNormal(double** aControls, int u, 
00105                              int v, int resolution);
00106 
00111   static csVector3 GetNormal(double** aControls, double u, double v);
00112 
00118   static csVector3 GetPoint(double** aControls, int u, int v, int resolution, 
00119                             double *map = NULL);
00120 
00126   static csVector2 GetTextureCoord(double** aControls, int u, int v, 
00127                                    int resolution, double *map = NULL);
00128 
00133   static csVector3 GetPoint(double** aControls, double u, double v, 
00134                             double (*func)(double, int, double, int) = NULL );
00135 };
00136 
00137 #endif // __CS_BEZIER_H__

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