Una humilde introducción a la graficación por computadora

Page 228

9 Curvas Paramétricas 139 140 141 142 143 144 145 146 147 148

}

149 150 151 152 153 154 155 156 157 158

}

i ++; for ( temp = temp - > sig ; temp != NULL ; temp = temp - > sig ) if ( i == ixBezier ) { nb = temp ; break ; } else i ++; // aquí se asume que siempre lo encuentra ... * x = _1_t3 * nb - > ant - > x [2] + 3* t1 * _1_t2 * nb - > x [0] + 3* t2 * _1_t1 * nb - > x [1] + t3 * nb - > x [2]; * y = _1_t3 * nb - > ant - > y [2] + 3* t1 * _1_t2 * nb - > y [0] + 3* t2 * _1_t1 * nb - > y [1] + t3 * nb - > y [2];

return BEZIER_COD_EXITO ;

int BEZIER_calculardeLista ( listaBezier * lista , double t , double *x , double *y , double * z ) { if ( lista == NULL || x == NULL || y == NULL || z == NULL ) return BEZIER_COD_ERROR_PARAMETROS ; if (t <0.0 || t >1.0) return BEZIER_COD_ERROR_DOMINIO ;

159

nodoBezier * temp = NULL , * nb = NULL ; int i =0 , j ;

160 161 162

// calcular el índice del nodo ' nodoBezier ' // con el que debe calcularse este 't ' int ixBezier = ( int ) ( t * lista - > numNodos ) ; if ( ixBezier == lista - > numNodos ) ixBezier - -;

163 164 165 166 167

t = lista - > numNodos * t - ixBezier ;

168 169

double double double double double double

170 171 172 173 174 175 176

t1 = t; t2 = t* t ; t3 = t2 * t ; _1_t1 = 1 - t ; _1_t2 = _1_t1 * _1_t1 ; _1_t3 = _1_t1 * _1_t2 ;

nb = temp = &( lista - > primero ) ; if ( ixBezier ==0) { // es el primer ' nodoBezier ' * x = _1_t3 * lista - > x + 3* t1 * _1_t2 * nb - > x [0] x [1] + t3 * nb - > x [2]; * y = _1_t3 * lista - > y + 3* t1 * _1_t2 * nb - > y [0] y [1] + t3 * nb - > y [2]; * z = _1_t3 * lista - > z + 3* t1 * _1_t2 * nb - > z [0] z [1] + t3 * nb - > z [2]; } else { // no es el primer ' nodoBezier ' con el que

177 178 179 180 181 182

228

+ 3* t2 * _1_t1 * nb - > + 3* t2 * _1_t1 * nb - > + 3* t2 * _1_t1 * nb - > se calculará 't '


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.