Go to the documentation of this file.00001 #ifndef OPENTISSUE_CORE_SPLINE_SPLINE_COMPUTE_SPLINE_DERIVATIVES_H
00002 #define OPENTISSUE_CORE_SPLINE_SPLINE_COMPUTE_SPLINE_DERIVATIVES_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 #include <OpenTissue/core/spline/spline_compute_basis_derivatives.h>
00013 #include <OpenTissue/core/spline/spline_compute_knot_span.h>
00014
00015 namespace OpenTissue
00016 {
00017 namespace spline
00018 {
00033 template<typename spline_type, typename math_types>
00034 inline void compute_spline_derivatives(
00035 spline_type const & s
00036 , typename spline_type::knot_container::value_type const & u
00037 , int J
00038 , typename spline_type::point_container & dQ
00039 , math_types const &
00040 )
00041 {
00042 using std::min;
00043
00044 typedef typename spline_type::knot_container knot_container;
00045 typedef typename spline_type::point_container point_container;
00046 typedef typename point_container::value_type vector_type;
00047 typedef typename math_types::matrix_type matrix_type;
00048
00049
00050 knot_container const & U = s.get_knot_container();
00051 point_container const & P = s.get_control_container();
00052
00053 int const k = s.get_order();
00054 int const dim = s.get_dimension();
00055 int const i = detail::compute_knot_span(u, k, U);
00056
00057
00058
00059 J = min(J,k-1);
00060
00061
00062 matrix_type dQ_basis;
00063
00064 detail::compute_basis_derivatives(u, J, k, U, dQ_basis);
00065
00066
00067
00068 dQ.clear();
00069
00070 vector_type tmp(dim);
00071 vector_type curr(dim);
00072
00073 for(int j=0; j<=J; ++j)
00074 {
00075 curr.clear();
00076 for(int nn=0; nn<=k-1; ++nn)
00077 {
00078 tmp = dQ_basis(j,nn) * P[i-k+1+nn];
00079 curr +=tmp;
00080 }
00081 dQ.push_back(curr);
00082 }
00083 }
00084
00085 }
00086 }
00087
00088
00089 #endif