X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FINTERP_KERNEL%2FTranslationRotationMatrix.hxx;h=90a0f1fa7067920ec7dceca9108e4a0ba45a61a4;hb=c241ded3d1997e10ee24c08f294c98c14eca956a;hp=e4c41a2144de61c8d7c3ccb3718c25f4b61b4535;hpb=1123dccd6613b2e8abba35182759d5c4a11ecc8d;p=tools%2Fmedcoupling.git diff --git a/src/INTERP_KERNEL/TranslationRotationMatrix.hxx b/src/INTERP_KERNEL/TranslationRotationMatrix.hxx index e4c41a214..90a0f1fa7 100644 --- a/src/INTERP_KERNEL/TranslationRotationMatrix.hxx +++ b/src/INTERP_KERNEL/TranslationRotationMatrix.hxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2014 CEA/DEN, EDF R&D +// Copyright (C) 2007-2016 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -119,7 +119,78 @@ namespace INTERP_KERNEL rotate_vector(P); } - + /** + * Fills in rotation_matrix so that the triangle PP1, PP2, PP3 is in the plane Oxy, with PP1 at the origin and PP2 on Ox. + */ + static void Rotate3DTriangle(const double* PP1,const double*PP2,const double*PP3, TranslationRotationMatrix& rotation_matrix) + { + double P1w[3]; + double P2w[3]; + double P3w[3]; + P2w[0]=PP2[0]; P2w[1]=PP2[1];P2w[2]=PP2[2]; + P3w[0]=PP3[0]; P3w[1]=PP3[1];P3w[2]=PP3[2]; + + // translating to set P1 at the origin + for (int i=0; i<3; i++) + { + P1w[i] = -PP1[i]; + P2w[i] -= PP1[i]; + P3w[i] -= PP1[i]; + } + + //initializes matrix + rotation_matrix.translate(P1w); + + // rotating to set P2 on the Oxy plane + TranslationRotationMatrix A; + A.rotate_x(P2w); + A.rotate_vector(P3w); + rotation_matrix.multiply(A); + + //rotating to set P2 on the Ox axis + TranslationRotationMatrix B; + B.rotate_z(P2w); + B.rotate_vector(P3w); + rotation_matrix.multiply(B); + + //rotating to set P3 on the Oxy plane + TranslationRotationMatrix C; + C.rotate_x(P3w); + rotation_matrix.multiply(C); + } + + /** + * Fills in rotation_matrix so that the bipoint PP1, PP2 is on the Ox axis. + */ + static void Rotate3DBipoint(const double* PP1,const double*PP2, TranslationRotationMatrix& rotation_matrix) + { + double P1w[3]; + double P2w[3]; + P2w[0]=PP2[0]; P2w[1]=PP2[1];P2w[2]=PP2[2]; + + // translating to set P1 at the origin + for (int i=0; i<3; i++) + { + P1w[i] = -PP1[i]; + P2w[i] -= PP1[i]; + } + + //initializes + rotation_matrix.translate(P1w); + + // rotating to set P2 on the Oxy plane + TranslationRotationMatrix A; + A.rotate_x(P2w); + rotation_matrix.multiply(A); + + //rotating to set P2 on the Ox axis + TranslationRotationMatrix B; + B.rotate_z(P2w); + rotation_matrix.multiply(B); + } + + + private: static const double EPS; static const unsigned ROT_SIZE=9;