1  /*


2  * f4_orientmat.cpp  Extension of Orient with matrix multiplication.


3  *


4  * f4genotype  f4 format genotype conversions for FramSticks


5  *


6  * Copyright (C) 1999,2000 Adam RotaruVarga (adam_rotaru@yahoo.com)


7  *


8  * This library is free software; you can redistribute it and/or


9  * modify it under the terms of the GNU Lesser General Public


10  * License as published by the Free Software Foundation; either


11  * version 2.1 of the License, or (at your option) any later version.


12  *


13  * This library is distributed in the hope that it will be useful,


14  * but WITHOUT ANY WARRANTY; without even the implied warranty of


15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU


16  * Lesser General Public License for more details.


17  *


18  * You should have received a copy of the GNU Lesser General Public


19  * License along with this library; if not, write to the Free Software


20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 021111307 USA


21  *


22  */


23 


24  #include "f4_orientmat.h"


25  #include <math.h>


26 


27 


28  f4_OrientMat::f4_OrientMat(XYZplanes plane, float angle)


29  {


30  switch(plane)


31  {


32  case xOy:


33  x.x = cos(angle); x.y = sin(angle); x.z = 0.0;


34  y.x = sin(angle); y.y = cos(angle); y.z = 0.0;


35  z.x = 0.0; z.y = 0.0; z.z = 1.0;


36  break;


37  case xOz:


38  x.x = cos(angle); x.y = 0.0; x.z = sin(angle);


39  y.x = 0.0; y.y = 1.0; y.z = 0.0;


40  z.x = sin(angle); z.y = 0.0; z.z = cos(angle);


41  break;


42  case yOz:


43  x.x = 1.0; x.y = 0.0; x.z = 0.0;


44  y.x = 0.0; y.y = cos(angle); y.z = sin(angle);


45  z.x = 0.0; z.y = sin(angle); z.z = cos(angle);


46  break;


47  }


48  }


49 


50 


51  // M3 = this * M2;


52  f4_OrientMat f4_OrientMat::operator*(const Orient & M2)


53  {


54  f4_OrientMat M3;


55  M3.x.x = x.x * M2.x.x + x.y * M2.y.x + x.z * M2.z.x;


56  M3.x.y = x.x * M2.x.y + x.y * M2.y.y + x.z * M2.z.y;


57  M3.x.z = x.x * M2.x.z + x.y * M2.y.z + x.z * M2.z.z;


58  M3.y.x = y.x * M2.x.x + y.y * M2.y.x + y.z * M2.z.x;


59  M3.y.y = y.x * M2.x.y + y.y * M2.y.y + y.z * M2.z.y;


60  M3.y.z = y.x * M2.x.z + y.y * M2.y.z + y.z * M2.z.z;


61  M3.z.x = z.x * M2.x.x + z.y * M2.y.x + z.z * M2.z.x;


62  M3.z.y = z.x * M2.x.y + z.y * M2.y.y + z.z * M2.z.y;


63  M3.z.z = z.x * M2.x.z + z.y * M2.y.z + z.z * M2.z.z;


64  return M3;


65  }

