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[ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /externals/g4tools/include/tools/lina/vec3f (Version 11.3.0) and /externals/g4tools/include/tools/lina/vec3f (Version 6.1)


  1 // Copyright (C) 2010, Guy Barrand. All rights    
  2 // See the file tools.license for terms.          
  3                                                   
  4 #ifndef tools_vec3f                               
  5 #define tools_vec3f                               
  6                                                   
  7 #include "vec3"                                   
  8 #include "../S_STRING"                            
  9 #include <cmath> //sqrt                           
 10                                                   
 11 namespace tools {                                 
 12                                                   
 13 class vec3f : public vec3<float> {                
 14   typedef vec3<float> parent;                     
 15 public:                                           
 16   TOOLS_SCLASS(tools::vec3f) //for stype()        
 17 public:                                           
 18   vec3f():parent(){}                              
 19   vec3f(const float a_vec[3]):parent(a_vec){}     
 20   vec3f(float a0,float a1,float a2):parent(a0,    
 21   virtual ~vec3f() {}                             
 22 public:                                           
 23   vec3f(const vec3f& a_from):parent(a_from){}     
 24   vec3f& operator=(const vec3f& a_from){          
 25     parent::operator=(a_from);                    
 26     return *this;                                 
 27   }                                               
 28                                                   
 29   vec3f(const parent& a_from):parent(a_from){}    
 30                                                   
 31 public: //operators                               
 32   vec3f operator*(float a_v) const {              
 33     return vec3f(m_data[0]*a_v,                   
 34                  m_data[1]*a_v,                   
 35                  m_data[2]*a_v);                  
 36   }                                               
 37   vec3f operator+(const vec3f& a_v) const {       
 38     return vec3f(m_data[0]+a_v.m_data[0],         
 39                  m_data[1]+a_v.m_data[1],         
 40                  m_data[2]+a_v.m_data[2]);        
 41   }                                               
 42   vec3f operator-(const vec3f& a_v) const {       
 43     return vec3f(m_data[0]-a_v.m_data[0],         
 44                  m_data[1]-a_v.m_data[1],         
 45                  m_data[2]-a_v.m_data[2]);        
 46   }                                               
 47   vec3f& operator+=(const vec3f& a_v) {           
 48     m_data[0] += a_v.m_data[0];                   
 49     m_data[1] += a_v.m_data[1];                   
 50     m_data[2] += a_v.m_data[2];                   
 51     return *this;                                 
 52   }                                               
 53   vec3f& operator-=(const vec3f& a_v) {           
 54     m_data[0] -= a_v.m_data[0];                   
 55     m_data[1] -= a_v.m_data[1];                   
 56     m_data[2] -= a_v.m_data[2];                   
 57     return *this;                                 
 58   }                                               
 59   vec3f& operator*=(float a_v) {                  
 60     m_data[0] *= a_v;                             
 61     m_data[1] *= a_v;                             
 62     m_data[2] *= a_v;                             
 63     return *this;                                 
 64   }                                               
 65   vec3f operator-() const {                       
 66     return vec3f(-m_data[0],-m_data[1],-m_data    
 67   }                                               
 68 public:                                           
 69 #define TOOLS_VEC3F_MORE_PREC                     
 70 #ifdef TOOLS_VEC3F_MORE_PREC                      
 71   float length() const {                          
 72     return float(::sqrt(m_data[0]*m_data[0]+m_    
 73   }                                               
 74   float normalize() {                             
 75     float norme = length();                       
 76     if(!norme) return 0;                          
 77     divide(norme);                                
 78     return norme;                                 
 79   }                                               
 80   bool cos_angle(const vec3f& a_v,float& a_cos    
 81     //WARNING : if ret false, a_cos is not set    
 82     float this_length = length();                 
 83     if(this_length==0.0f) return false;           
 84     float a_v_length = a_v.length();              
 85     if(a_v_length==0.0f) return false;            
 86     a_cos = dot(a_v)/(this_length*a_v_length);    
 87     return true;                                  
 88   }                                               
 89 #else                                             
 90   float length() const {return parent::length(    
 91   float normalize() {return parent::normalize(    
 92   bool cos_angle(const vec3f& a_v,float& a_cos    
 93 #endif                                            
 94                                                   
 95   bool theta_phi(float& a_theta,float& a_phi)     
 96     return parent::theta_phi(a_theta,a_phi,::s    
 97   }                                               
 98 public: //iv2sg                                   
 99   bool equals(const vec3f& a_v,const float a_e    
100     //if(a_epsil<0.0f))                           
101     float d0 = m_data[0]-a_v.m_data[0];           
102     float d1 = m_data[1]-a_v.m_data[1];           
103     float d2 = m_data[2]-a_v.m_data[2];           
104     return ((d0*d0+d1*d1+d2*d2)<=a_epsil);        
105   }                                               
106   void negate() {                                 
107     m_data[0] = -m_data[0];                       
108     m_data[1] = -m_data[1];                       
109     m_data[2] = -m_data[2];                       
110   }                                               
111                                                   
112 private:static void check_instantiation() {vec    
113 };                                                
114                                                   
115 inline vec3f operator*(float a_f,const vec3f&     
116   vec3f res(a_v);                                 
117   res *= a_f;                                     
118   return res;                                     
119 }                                                 
120                                                   
121 #define TOOLS_VEC3F_MORE_PREC                     
122 #ifdef TOOLS_VEC3F_MORE_PREC                      
123 inline void get_normal(const vec3f& a_p0,const    
124                        vec3f& a_tmp_1,vec3f& a    
125   // Used to optimize sg::bin().                  
126   //(a_p1-a_p0).cross(a_p2-a_p1,a_nm);            
127                                                   
128   a_tmp_1 = a_p1;                                 
129   a_tmp_1.subtract(a_p0);                         
130                                                   
131   a_tmp_2 = a_p2;                                 
132   a_tmp_2.subtract(a_p1);                         
133                                                   
134   a_tmp_1.cross(a_tmp_2,a_nm);                    
135                                                   
136   a_nm.normalize();                               
137 }                                                 
138 #else                                             
139 inline void get_normal(const vec3f& a_p0,const    
140                        vec3f& a_tmp_1,vec3f& a    
141   get_normal<float>(a_p0,a_p1,a_p2,a_nm,a_tmp_    
142 }                                                 
143 #endif                                            
144                                                   
145 }                                                 
146                                                   
147 #include <vector>                                 
148                                                   
149 namespace tools {                                 
150                                                   
151 #ifndef SWIG                                      
152 //for sf, mf :                                    
153 inline bool set_from_vec(vec3f& a_v,const std:    
154   if(a_sv.size()!=3) return false;                
155   a_v[0] = a_sv[0];                               
156   a_v[1] = a_sv[1];                               
157   a_v[2] = a_sv[2];                               
158   return true;                                    
159 }                                                 
160 #endif                                            
161                                                   
162 }                                                 
163                                                   
164 #endif