7 #ifndef __FWRENDERQT_BSPLINE_HPP__ 8 #define __FWRENDERQT_BSPLINE_HPP__ 15 #define DEFAULT_PRECISION 40 22 point(
float _x = 0.f,
float _y = 0.f) :
54 this->m_list = _which.m_list;
58 for (
unsigned int i = 0; i < m_list.size(); i++)
66 point& get_point(
int which)
68 point* pt = m_list.at(which);
74 void add_point(
point* _which)
76 m_list.push_back(_which);
79 std::vector<point*> m_list;
87 m_curve_point(
nullptr),
89 m_nb_point(m_plist->m_list.size()),
90 m_precision(DEFAULT_PRECISION),
97 if (m_curve_point !=
nullptr)
99 delete[] m_curve_point;
107 if (m_curve_point !=
nullptr)
109 delete[] m_curve_point;
111 m_curve_point =
new point[m_precision+1];
112 m_nb_curve_point = m_precision+1;
114 float t = 1.0f, p = (float)(m_nb_point-3)/(float)m_precision;
118 for(
int k = 0; k < m_nb_curve_point; k++)
122 if (i < m_nb_point-2)
125 (3.0f*m_plist->m_list[i]->x-3.0f*m_plist->m_list[i+1]->x+
126 m_plist->m_list[i+2]->x-m_plist->m_list[i-1]->x)*pow(t-ti, 3)/2.0f+
127 ( 2.0f*m_plist->m_list[i-1]->x - 5.0f*m_plist->m_list[i]->x +
128 4.0f*m_plist->m_list[i+1]->x - m_plist->m_list[i+2]->x)*pow(t-ti, 2)/2.0f+
129 ( m_plist->m_list[i+1]->x - m_plist->m_list[i-1]->x ) *(t-ti)/2.0f + m_plist->m_list[i]->x;
132 (3.0f*m_plist->m_list[i]->y-3.0f*m_plist->m_list[i+1]->y+
133 m_plist->m_list[i+2]->y-m_plist->m_list[i-1]->y)*pow(t-ti, 3)/2.0f+
134 ( 2.0f*m_plist->m_list[i-1]->y - 5.0f*m_plist->m_list[i]->y +
135 4.0f*m_plist->m_list[i+1]->y - m_plist->m_list[i+2]->y)*pow(t-ti, 2)/2.0f+
136 ( m_plist->m_list[i+1]->y - m_plist->m_list[i-1]->y ) *(t-ti)/2.0f + m_plist->m_list[i]->y;
138 else if(i < m_nb_point)
140 m_curve_point[k].x = m_plist->m_list[i]->x;
141 m_curve_point[k].y = m_plist->m_list[i]->y;
148 point* m_curve_point;
149 int m_nb_curve_point;
158 #endif //__FWRENDERQT_BSPLINE_HPP__