diff --git a/Graphics/Entity.cpp b/Graphics/Entity.cpp index bc676d1bb3742b3915c24eea9eddbe50998ff649..4eedfe7f6f22ce7677c2a4183b91b99a095366b5 100644 --- a/Graphics/Entity.cpp +++ b/Graphics/Entity.cpp @@ -1,4 +1,4 @@ -// $Id: Entity.cpp,v 1.33 2004-04-13 18:47:32 geuzaine Exp $ +// $Id: Entity.cpp,v 1.34 2004-04-13 19:27:09 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -56,7 +56,7 @@ void Draw_Sphere(double size, double x, double y, double z, int light) glEndList(); } glPushMatrix(); - glTranslatef(x, y, z); + glTranslated(x, y, z); glScalef(s, s, s); glCallList(listnum); glPopMatrix(); @@ -86,11 +86,16 @@ void Draw_Cylinder(double width, double *x, double *y, double *z, int light) double vdir[3] = {dx/length, dy/length, dz/length}; double axis[3], cosphi, phi; prodve(zdir, vdir, axis); - norme(axis); prosca(zdir, vdir, &cosphi); + if(!norme(axis)){ + axis[0] = 0.; + axis[1] = 1.; + axis[2] = 0.; + } phi = 180. * myacos(cosphi) / M_PI; - glTranslatef(x[0], y[0], z[0]); - glRotatef(phi, axis[0], axis[1], axis[2]); + + glTranslated(x[0], y[0], z[0]); + glRotated(phi, axis[0], axis[1], axis[2]); gluCylinder(qua, radius, radius, length, CTX.quadric_subdivisions, 1); glPopMatrix(); @@ -349,18 +354,22 @@ void Draw_3DArrow(double relHeadRadius, double relStemLength, double relStemRadi double vdir[3] = {dx/length, dy/length, dz/length}; double axis[3], cosphi, phi; prodve(zdir, vdir, axis); - norme(axis); prosca(zdir, vdir, &cosphi); + if(!norme(axis)){ + axis[0] = 0.; + axis[1] = 1.; + axis[2] = 0.; + } phi = 180. * myacos(cosphi) / M_PI; - glTranslatef(x, y, z); - glRotatef(phi, axis[0], axis[1], axis[2]); + glTranslated(x, y, z); + glRotated(phi, axis[0], axis[1], axis[2]); if(head_l && head_r){ - glTranslatef(0., 0., stem_l); + glTranslated(0., 0., stem_l); gluCylinder(qua, head_r, 0., head_l, subdiv, 1); gluDisk(qua, stem_r, head_r, subdiv, 1); - glTranslatef(0., 0., -stem_l); + glTranslated(0., 0., -stem_l); } if(stem_l && stem_r){ diff --git a/Numeric/Numeric.cpp b/Numeric/Numeric.cpp index d18dd6bfc888cf06a4270235a37a0a267c25a4ef..96a51c2704ccd5337e5657bcc1971c889d4b8e39 100644 --- a/Numeric/Numeric.cpp +++ b/Numeric/Numeric.cpp @@ -1,4 +1,4 @@ -// $Id: Numeric.cpp,v 1.12 2004-04-13 18:47:32 geuzaine Exp $ +// $Id: Numeric.cpp,v 1.13 2004-04-13 19:27:09 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -106,15 +106,15 @@ void prosca(double a[3], double b[3], double *c) *c = a[0] * b[0] + a[1] * b[1] + a[2] * b[2]; } -void norme(double a[3]) +double norme(double a[3]) { - double mod; - mod = sqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2]); - if(mod == 0.0) - return; - a[0] /= mod; - a[1] /= mod; - a[2] /= mod; + double mod = sqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2]); + if(mod != 0.0){ + a[0] /= mod; + a[1] /= mod; + a[2] /= mod; + } + return mod; } int sys2x2(double mat[2][2], double b[2], double res[2]) diff --git a/Numeric/Numeric.h b/Numeric/Numeric.h index 52d5270ab713eb7728e29ba9308b0c10172374eb..bddcf1eef4e1b9f4f0579bfa4a34401044aea99f 100644 --- a/Numeric/Numeric.h +++ b/Numeric/Numeric.h @@ -61,7 +61,7 @@ double myasin(double a); double myacos(double a); void prodve(double a[3], double b[3], double c[3]); void prosca(double a[3], double b[3], double *c); -void norme(double a[3]); +double norme(double a[3]); int sys2x2(double mat[2][2], double b[2], double res[2]); int sys3x3(double mat[3][3], double b[3], double res[3], double *det); int sys3x3_with_tol(double mat[3][3], double b[3], double res[3], double *det);