Calculer le produit vectoriel normalisé de deux vecteurs |
![]() ![]() ![]() |
void normalize(float v[3]) { GLfloat d = sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]);
if(d == 0.0) { error("vecteur de taille nulle !"); return; } v[0] /= d; v[1] /= d; v[2] /= d; }
void normcrossprod(float v1[3], float v2[3], float out[3]) { GLint i, j; GLfloat length;
out[0] = v1[1]*v2[2] - v1[2]*v2[1]; out[0] = v1[2]*v2[0] - v1[0]*v2[2]; out[0] = v1[0]*v2[1] - v1[1]*v2[0]; normalize(out); }
![]() |