Geant4 Cross Reference |
1 // Copyright (C) 2010, Guy Barrand. All rights 1 // Copyright (C) 2010, Guy Barrand. All rights reserved. 2 // See the file tools.license for terms. 2 // See the file tools.license for terms. 3 3 4 #ifndef tools_mat4f 4 #ifndef tools_mat4f 5 #define tools_mat4f 5 #define tools_mat4f 6 6 7 #include "mat4" 7 #include "mat4" 8 #include <cmath> 8 #include <cmath> 9 9 10 namespace tools { 10 namespace tools { 11 11 12 class mat4f : public mat4<float> { 12 class mat4f : public mat4<float> { 13 typedef mat4<float> parent; 13 typedef mat4<float> parent; 14 public: 14 public: 15 mat4f(){} 15 mat4f(){} 16 virtual ~mat4f() {} 16 virtual ~mat4f() {} 17 public: 17 public: 18 mat4f(const mat4f& a_from):parent(a_from){} 18 mat4f(const mat4f& a_from):parent(a_from){} 19 mat4f& operator=(const mat4f& a_from){ 19 mat4f& operator=(const mat4f& a_from){ 20 parent::operator=(a_from); 20 parent::operator=(a_from); 21 return *this; 21 return *this; 22 } 22 } 23 public: 23 public: 24 mat4f(float a_00,float a_01,float a_02,float 24 mat4f(float a_00,float a_01,float a_02,float a_03, //first row 25 float a_10,float a_11,float a_12,float 25 float a_10,float a_11,float a_12,float a_13, //second row 26 float a_20,float a_21,float a_22,float 26 float a_20,float a_21,float a_22,float a_23, //third row 27 float a_30,float a_31,float a_32,float 27 float a_30,float a_31,float a_32,float a_33) //fourth row 28 :parent(a_00,a_01,a_02,a_03, 28 :parent(a_00,a_01,a_02,a_03, 29 a_10,a_11,a_12,a_13, 29 a_10,a_11,a_12,a_13, 30 a_20,a_21,a_22,a_23, 30 a_20,a_21,a_22,a_23, 31 a_30,a_31,a_32,a_33) 31 a_30,a_31,a_32,a_33) 32 {} 32 {} 33 mat4f(const parent& a_from):parent(a_from){} 33 mat4f(const parent& a_from):parent(a_from){} 34 mat4f& operator=(const parent& a_from){ 34 mat4f& operator=(const parent& a_from){ 35 parent::operator=(a_from); 35 parent::operator=(a_from); 36 return *this; 36 return *this; 37 } 37 } 38 public: 38 public: 39 void set_rotate(const float& a_x,const float 39 void set_rotate(const float& a_x,const float& a_y,const float& a_z,const float& a_angle) { 40 //WARNING : (a_x,a_y,a_z) must be a normal 40 //WARNING : (a_x,a_y,a_z) must be a normalized vector. 41 parent::set_rotate(a_x,a_y,a_z,a_angle,::s 41 parent::set_rotate(a_x,a_y,a_z,a_angle,::sinf,::cosf); 42 } 42 } 43 void mul_rotate(const float& a_x,const float 43 void mul_rotate(const float& a_x,const float& a_y,const float& a_z,const float& a_angle) { 44 parent::mul_rotate(a_x,a_y,a_z,a_angle,::s 44 parent::mul_rotate(a_x,a_y,a_z,a_angle,::sinf,::cosf); 45 } 45 } 46 void left_mul_rotate(const float& a_x,const 46 void left_mul_rotate(const float& a_x,const float& a_y,const float& a_z,const float& a_angle) { 47 parent::left_mul_rotate(a_x,a_y,a_z,a_angl 47 parent::left_mul_rotate(a_x,a_y,a_z,a_angle,::sinf,::cosf); 48 } 48 } 49 49 50 template <class VEC> 50 template <class VEC> 51 void set_rotate(const VEC& a_dir,float a_ang 51 void set_rotate(const VEC& a_dir,float a_angle) { 52 //WARNING : a_dir must be a normalized vec 52 //WARNING : a_dir must be a normalized vector. 53 parent::set_rotate(a_dir[0],a_dir[1],a_dir 53 parent::set_rotate(a_dir[0],a_dir[1],a_dir[2],a_angle,::sinf,::cosf); 54 } 54 } 55 55 56 public: //backward compatibility 56 public: //backward compatibility 57 void mul_2f(float& a_x,float& a_y) const {pa 57 void mul_2f(float& a_x,float& a_y) const {parent::mul_2(a_x,a_y);} 58 void mul_3f(float& a_x,float& a_y,float& a_z 58 void mul_3f(float& a_x,float& a_y,float& a_z) const {parent::mul_3(a_x,a_y,a_z);} 59 void mul_3f_opt(float& a_x,float& a_y,float& << 60 void mul_dir_3f(float& a_x,float& a_y,float& 59 void mul_dir_3f(float& a_x,float& a_y,float& a_z) const {parent::mul_dir_3(a_x,a_y,a_z);} 61 void mul_dir_3f_opt(float& a_x,float& a_y,fl << 62 void mul_trans_3f(float& a_x,float& a_y,floa 60 void mul_trans_3f(float& a_x,float& a_y,float& a_z) const {parent::mul_trans_3(a_x,a_y,a_z);} 63 void mul_4f(float& a_x,float& a_y,float& a_z 61 void mul_4f(float& a_x,float& a_y,float& a_z,float& a_w) const {parent::mul_4(a_x,a_y,a_z,a_w);} 64 void mul_4f_opt(float& a_x,float& a_y,float& << 65 void mul_dir_3d(double& a_x,double& a_y,doub 62 void mul_dir_3d(double& a_x,double& a_y,double& a_z) const { //used in sg::healpix 66 float x = float(a_x); 63 float x = float(a_x); 67 float y = float(a_y); 64 float y = float(a_y); 68 float z = float(a_z); 65 float z = float(a_z); 69 parent::mul_dir_3(x,y,z); 66 parent::mul_dir_3(x,y,z); 70 a_x = x;a_y = y;a_z = z; 67 a_x = x;a_y = y;a_z = z; 71 } 68 } 72 public: //operators 69 public: //operators 73 }; 70 }; 74 71 75 // for sf_vec<mat4f,float>, sf_mat4f : 72 // for sf_vec<mat4f,float>, sf_mat4f : 76 inline const std::string& stype(const mat4f&) 73 inline const std::string& stype(const mat4f&) { 77 static const std::string s_v("tools::mat4f") 74 static const std::string s_v("tools::mat4f"); 78 return s_v; 75 return s_v; 79 } 76 } 80 77 81 } 78 } 82 79 83 #endif 80 #endif