00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00020 #ifndef SHLIBSPLINESIMPL_HPP
00021 #define SHLIBSPLINESIMPL_HPP
00022
00023 #include "ShLibSplines.hpp"
00024 #include "ShDebug.hpp"
00025
00026 namespace SH {
00027
00028 template<int N, typename T>
00029 ShGeneric<N, T> bernstein(const ShGeneric<1, T>& a)
00030 {
00031 ShAttrib<N, SH_TEMP, T> result;
00032 if (4 == N) {
00033 ShAttrib<1, SH_TEMP, T> it = ShAttrib<1,SH_TEMP, T>(1.0f) - a;
00034 result(0) = it*it*it;
00035 result(1) = 3.0*it*it*a;
00036 result(2) = 3.0*it*a*a;
00037 result(3) = a*a*a;
00038 }
00039 else {
00040
00041 SH_DEBUG_WARN("bernstein is not fully implemented yet");
00042 for (int i=0; i < N; i++) {
00043 result[i] = a[0];
00044 }
00045 }
00046 return result;
00047 }
00048
00049 template <int N, typename T>
00050 ShGeneric<N, T> bezier(const ShGeneric<1, T>& t, const ShGeneric<N, T>& p)
00051 {
00052 ShAttrib<N, SH_TEMP, T> B = bernstein<N>(t(0));
00053 ShAttrib<N, SH_TEMP, T> r;
00054 r(0) = B[0] * p[0];
00055 for (int i=1; i < N; i++) {
00056 r(i) = B[i] * p[i];
00057 }
00058 return r;
00059 }
00060
00061 template <int N, typename T>
00062 ShGeneric<N, T> hermite(const ShGeneric<1, T>& a, const ShGeneric<N, T>& b,
00063 const ShGeneric<N, T>& c, const ShGeneric<N, T>& d,
00064 const ShGeneric<N, T>& e)
00065 {
00066 ShAttrib<N, SH_TEMP, T> result;
00067
00068
00069 SH_DEBUG_WARN("hermite is not implemented yet");
00070 for (int i=0; i < N; i++) {
00071 result[i] = a[0];
00072 }
00073
00074 return result;
00075 }
00076
00077 }
00078
00079 #endif