g4tools  5.4.0
Public Member Functions | Static Protected Member Functions | List of all members
tools::mat4< T > Class Template Reference
Inheritance diagram for tools::mat4< T >:
Inheritance graph
[legend]
Collaboration diagram for tools::mat4< T >:
Collaboration graph
[legend]

Public Member Functions

 mat4 ()
 
 mat4 (const mat< T, 4 > &a_from)
 
virtual ~mat4 ()
 
 mat4 (const mat4 &a_from)
 
mat4operator= (const mat4 &a_from)
 
 mat4 (const T &a_00, const T &a_01, const T &a_02, const T &a_03, const T &a_10, const T &a_11, const T &a_12, const T &a_13, const T &a_20, const T &a_21, const T &a_22, const T &a_23, const T &a_30, const T &a_31, const T &a_32, const T &a_33)
 
void set_matrix (const mat4< T > &a_m)
 
void set_matrix (const T &a_00, const T &a_01, const T &a_02, const T &a_03, const T &a_10, const T &a_11, const T &a_12, const T &a_13, const T &a_20, const T &a_21, const T &a_22, const T &a_23, const T &a_30, const T &a_31, const T &a_32, const T &a_33)
 
void set_scale (const T &a_s)
 
void set_scale (const T &a_1, const T &a_2, const T &a_3)
 
void set_translate (const T &a_x, const T &a_y, const T &a_z)
 
void set_rotate (const T &a_x, const T &a_y, const T &a_z, const T &a_angle, T(*a_sin)(T), T(*a_cos)(T))
 
void set_ortho (const T &a_l, const T &a_r, const T &a_b, const T &a_t, const T &a_n, const T &a_f)
 
void set_frustum (const T &a_l, const T &a_r, const T &a_b, const T &a_t, const T &a_n, const T &a_f)
 
void get_translate (T &a_x, T &a_y, T &a_z) const
 
void no_translate ()
 
void mul_4 (T &a_x, T &a_y, T &a_z, T &a_p) const
 
void mul_3 (T &a_x, T &a_y, T &a_z) const
 
void mul_2 (T &a_x, T &a_y) const
 
void mul_dir_3 (T &a_x, T &a_y, T &a_z) const
 
void mul_trans_3 (T &a_x, T &a_y, T &a_z) const
 
template<class VEC >
void mul_dir_3 (VEC &a_dir) const
 
void mul_scale (const T &a_sx, const T &a_sy, const T &a_sz)
 
void mul_scale (const T &a_s)
 
void mul_translate (const T &a_x, const T &a_y, const T &a_z)
 
void mul_rotate (const T &a_x, const T &a_y, const T &a_z, const T &a_angle, T(*a_sin)(T), T(*a_cos)(T))
 
void left_mul_rotate (const T &a_x, const T &a_y, const T &a_z, const T &a_angle, T(*a_sin)(T), T(*a_cos)(T))
 
void left_mul_scale (const T &a_x, const T &a_y, const T &a_z)
 
void left_mul_translate (const T &a_x, const T &a_y, const T &a_z)
 
void v00 (const T &a_value)
 
void v10 (const T &a_value)
 
void v20 (const T &a_value)
 
void v30 (const T &a_value)
 
void v01 (const T &a_value)
 
void v11 (const T &a_value)
 
void v21 (const T &a_value)
 
void v31 (const T &a_value)
 
void v02 (const T &a_value)
 
void v12 (const T &a_value)
 
void v22 (const T &a_value)
 
void v32 (const T &a_value)
 
void v03 (const T &a_value)
 
void v13 (const T &a_value)
 
void v23 (const T &a_value)
 
void v33 (const T &a_value)
 
const T & v00 () const
 
const T & v10 () const
 
const T & v20 () const
 
const T & v30 () const
 
const T & v01 () const
 
const T & v11 () const
 
const T & v21 () const
 
const T & v31 () const
 
const T & v02 () const
 
const T & v12 () const
 
const T & v22 () const
 
const T & v32 () const
 
const T & v03 () const
 
const T & v13 () const
 
const T & v23 () const
 
const T & v33 () const
 
void mul_mtx_rot_root (const T &a_00, const T &a_01, const T &a_02, const T &a_10, const T &a_11, const T &a_12, const T &a_20, const T &a_21, const T &a_22)
 
template<class MAT3 >
void set_mat3 (MAT3 &a_m3)
 
- Public Member Functions inherited from tools::mat< T, 4 >
 mat ()
 
 mat (const mat &a_from)
 
 mat (const T a_v[])
 
virtual ~mat ()
 
matoperator= (const mat &a_from)
 
unsigned int dimension () const
 

Static Protected Member Functions

static void _set_translate (const T &a_x, const T &a_y, const T &a_z, T v[])
 
static void _set_scale (const T &a_1, const T &a_2, const T &a_3, T v[])
 
static void _set_rotate (const T &a_x, const T &a_y, const T &a_z, const T &a_angle, T v[], T(*a_sin)(T), T(*a_cos)(T))
 

Additional Inherited Members

- Protected Attributes inherited from tools::mat< T, 4 >
m_vec [D *D]
 

Detailed Description

template<class T>
class tools::mat4< T >

Definition at line 14 of file mat4.

Constructor & Destructor Documentation

◆ mat4() [1/4]

template<class T >
tools::mat4< T >::mat4 ( )
inline

Definition at line 21 of file mat4.

21 :parent() {}

◆ mat4() [2/4]

template<class T >
tools::mat4< T >::mat4 ( const mat< T, 4 > &  a_from)
inline

Definition at line 23 of file mat4.

23 :parent(a_from){}

◆ ~mat4()

template<class T >
virtual tools::mat4< T >::~mat4 ( )
inlinevirtual

Definition at line 24 of file mat4.

24 {}

◆ mat4() [3/4]

template<class T >
tools::mat4< T >::mat4 ( const mat4< T > &  a_from)
inline

Definition at line 26 of file mat4.

26 :parent(a_from){}

◆ mat4() [4/4]

template<class T >
tools::mat4< T >::mat4 ( const T &  a_00,
const T &  a_01,
const T &  a_02,
const T &  a_03,
const T &  a_10,
const T &  a_11,
const T &  a_12,
const T &  a_13,
const T &  a_20,
const T &  a_21,
const T &  a_22,
const T &  a_23,
const T &  a_30,
const T &  a_31,
const T &  a_32,
const T &  a_33 
)
inline

Definition at line 32 of file mat4.

36  {
37  set_matrix(a_00,a_01,a_02,a_03,
38  a_10,a_11,a_12,a_13,
39  a_20,a_21,a_22,a_23,
40  a_30,a_31,a_32,a_33);
41  }

Member Function Documentation

◆ _set_rotate()

template<class T >
static void tools::mat4< T >::_set_rotate ( const T &  a_x,
const T &  a_y,
const T &  a_z,
const T &  a_angle,
v[],
T(*)(T)  a_sin,
T(*)(T)  a_cos 
)
inlinestaticprotected

Definition at line 358 of file mat4.

358  {
359  //WARNING : (a_x,a_y,a_z) must be a normalized vector.
360  // v[] = exp(-a_angle*n(a_x,a_y,a_z)*Rs). It models the rotation of an object in the same coordinate system (active rotation).
361  T si = a_sin(a_angle);
362  T co = a_cos(a_angle);
363  T x = a_x;
364  T y = a_y;
365  T z = a_z;
366  T x2 = x*x;
367  T y2 = y*y;
368  T z2 = z*z;
369  T xy = x*y;
370  T xz = x*z;
371  T yz = y*z;
372  v[0] = x2+(1-x2)*co;v[4] = xy*(1-co)-z*si;v[ 8] = xz*(1-co)+y*si;v[12] = 0;
373  v[1] = xy*(1-co)+z*si;v[5] = y2+(1-y2)*co;v[ 9] = yz*(1-co)-x*si;v[13] = 0;
374  v[2] = xz*(1-co)-y*si;v[6] = yz*(1-co)+x*si;v[10] = z2+(1-z2)*co;v[14] = 0;
375  v[3] = 0;v[7] = 0;v[11] = 0;v[15] = 1;
376 
377  // If :
378  // n =(x,y,z)
379  // n2 = x2+y2+z2 = 1
380  // n.E = x*E1+y*E2+z*E3
381  // with :
382  // E1 E2 E3
383  // 0 0 0 0 0 -1 0 1 0
384  // 0 0 1 0 0 0 -1 0 0
385  // 0 -1 0 1 0 0 0 0 0
386  //
387  // R(r,c) = cos(theta)*Id(r,c)+(1-cos(theta))*nr*nc-sin(theta)*(n.E)(r,c)
388  //
389  // R = exp(-theta*(n.E)) // active rotation (it models the rotation of an object by theta along n).
390 
391  }

◆ _set_scale()

template<class T >
static void tools::mat4< T >::_set_scale ( const T &  a_1,
const T &  a_2,
const T &  a_3,
v[] 
)
inlinestaticprotected

Definition at line 351 of file mat4.

351  {
352  v[0] = a_1;v[4] = 0;v[ 8] = 0;v[12] = 0;
353  v[1] = 0;v[5] = a_2;v[ 9] = 0;v[13] = 0;
354  v[2] = 0;v[6] = 0;v[10] = a_3;v[14] = 0;
355  v[3] = 0;v[7] = 0;v[11] = 0;v[15] = T(1);
356  }

◆ _set_translate()

template<class T >
static void tools::mat4< T >::_set_translate ( const T &  a_x,
const T &  a_y,
const T &  a_z,
v[] 
)
inlinestaticprotected

Definition at line 344 of file mat4.

344  {
345  v[0] = T(1);v[4] = 0;v[ 8] = 0;v[12] = a_x;
346  v[1] = 0;v[5] = T(1);v[ 9] = 0;v[13] = a_y;
347  v[2] = 0;v[6] = 0;v[10] = T(1);v[14] = a_z;
348  v[3] = 0;v[7] = 0;v[11] = 0;v[15] = T(1);
349  }

◆ get_translate()

template<class T >
void tools::mat4< T >::get_translate ( T &  a_x,
T &  a_y,
T &  a_z 
) const
inline

Definition at line 149 of file mat4.

149  {
150  a_x = pr::m_vec[12];
151  a_y = pr::m_vec[13];
152  a_z = pr::m_vec[14];
153  }

◆ left_mul_rotate()

template<class T >
void tools::mat4< T >::left_mul_rotate ( const T &  a_x,
const T &  a_y,
const T &  a_z,
const T &  a_angle,
T(*)(T)  a_sin,
T(*)(T)  a_cos 
)
inline

Definition at line 285 of file mat4.

285  {
286  T _m[16];
287  _set_rotate(a_x,a_y,a_z,a_angle,_m,a_sin,a_cos);
288  parent::_left_mul_mtx(_m);
289  }

◆ left_mul_scale()

template<class T >
void tools::mat4< T >::left_mul_scale ( const T &  a_x,
const T &  a_y,
const T &  a_z 
)
inline

Definition at line 291 of file mat4.

291  {
292  T _m[16];
293  _set_scale(a_x,a_y,a_z,_m);
294  parent::_left_mul_mtx(_m);
295  }

◆ left_mul_translate()

template<class T >
void tools::mat4< T >::left_mul_translate ( const T &  a_x,
const T &  a_y,
const T &  a_z 
)
inline

Definition at line 297 of file mat4.

297  {
298  T _m[16];
299  _set_translate(a_x,a_y,a_z,_m);
300  parent::_left_mul_mtx(_m);
301  }

◆ mul_2()

template<class T >
void tools::mat4< T >::mul_2 ( T &  a_x,
T &  a_y 
) const
inline

Definition at line 198 of file mat4.

198  {
199  // a_[x,y] = this * a_[x,y]
200  //pr::m_vec[R + C * 4];
201  //pr::m_vec[0]= 00;pr::m_vec[4] = 01;pr::m_vec[ 8] = 02;pr::m_vec[12] = 03;
202  //pr::m_vec[1]= 10;pr::m_vec[5] = 11;pr::m_vec[ 9] = 12;pr::m_vec[13] = 13;
203  //pr::m_vec[2]= 20;pr::m_vec[6] = 21;pr::m_vec[10] = 22;pr::m_vec[14] = 23;
204  //pr::m_vec[3]= 30;pr::m_vec[7] = 31;pr::m_vec[11] = 32;pr::m_vec[15] = 33;
205  T x = pr::m_vec[0]*a_x+pr::m_vec[4]*a_y+pr::m_vec[12];
206  T y = pr::m_vec[1]*a_x+pr::m_vec[5]*a_y+pr::m_vec[13];
207  a_x = x;
208  a_y = y;
209  }

◆ mul_3()

template<class T >
void tools::mat4< T >::mul_3 ( T &  a_x,
T &  a_y,
T &  a_z 
) const
inline

Definition at line 184 of file mat4.

184  {
185  // a_[x,y,z] = this * a_[x,y,z]
186  //pr::m_vec[R + C * 4];
187  //pr::m_vec[0]= 00;pr::m_vec[4] = 01;pr::m_vec[ 8] = 02;pr::m_vec[12] = 03;
188  //pr::m_vec[1]= 10;pr::m_vec[5] = 11;pr::m_vec[ 9] = 12;pr::m_vec[13] = 13;
189  //pr::m_vec[2]= 20;pr::m_vec[6] = 21;pr::m_vec[10] = 22;pr::m_vec[14] = 23;
190  //pr::m_vec[3]= 30;pr::m_vec[7] = 31;pr::m_vec[11] = 32;pr::m_vec[15] = 33;
191  T x = pr::m_vec[0]*a_x+pr::m_vec[4]*a_y+pr::m_vec[ 8]*a_z+pr::m_vec[12];
192  T y = pr::m_vec[1]*a_x+pr::m_vec[5]*a_y+pr::m_vec[ 9]*a_z+pr::m_vec[13];
193  T z = pr::m_vec[2]*a_x+pr::m_vec[6]*a_y+pr::m_vec[10]*a_z+pr::m_vec[14];
194  a_x = x;
195  a_y = y;
196  a_z = z;
197  }

◆ mul_4()

template<class T >
void tools::mat4< T >::mul_4 ( T &  a_x,
T &  a_y,
T &  a_z,
T &  a_p 
) const
inline

Definition at line 168 of file mat4.

168  {
169  // a_[x,y,z,p] = this * a_[x,y,z,p]
170  //pr::m_vec[R + C * 4];
171  //pr::m_vec[0]= 00;pr::m_vec[4] = 01;pr::m_vec[ 8] = 02;pr::m_vec[12] = 03;
172  //pr::m_vec[1]= 10;pr::m_vec[5] = 11;pr::m_vec[ 9] = 12;pr::m_vec[13] = 13;
173  //pr::m_vec[2]= 20;pr::m_vec[6] = 21;pr::m_vec[10] = 22;pr::m_vec[14] = 23;
174  //pr::m_vec[3]= 30;pr::m_vec[7] = 31;pr::m_vec[11] = 32;pr::m_vec[15] = 33;
175  T x= pr::m_vec[0]*a_x+pr::m_vec[4]*a_y+pr::m_vec[ 8]*a_z+pr::m_vec[12]*a_p;
176  T y= pr::m_vec[1]*a_x+pr::m_vec[5]*a_y+pr::m_vec[ 9]*a_z+pr::m_vec[13]*a_p;
177  T z= pr::m_vec[2]*a_x+pr::m_vec[6]*a_y+pr::m_vec[10]*a_z+pr::m_vec[14]*a_p;
178  T p= pr::m_vec[3]*a_x+pr::m_vec[7]*a_y+pr::m_vec[11]*a_z+pr::m_vec[15]*a_p;
179  a_x = x;
180  a_y = y;
181  a_z = z;
182  a_p = p;
183  }

◆ mul_dir_3() [1/2]

template<class T >
void tools::mat4< T >::mul_dir_3 ( T &  a_x,
T &  a_y,
T &  a_z 
) const
inline

Definition at line 211 of file mat4.

211  {
212  // used to multiply normals.
213  // a_[x,y,z] = rot_part(this) * a_[x,y,z]
214 
215  T x = pr::m_vec[0]*a_x+pr::m_vec[4]*a_y+pr::m_vec[ 8]*a_z;
216  T y = pr::m_vec[1]*a_x+pr::m_vec[5]*a_y+pr::m_vec[ 9]*a_z;
217  T z = pr::m_vec[2]*a_x+pr::m_vec[6]*a_y+pr::m_vec[10]*a_z;
218  a_x = x;
219  a_y = y;
220  a_z = z;
221  }

◆ mul_dir_3() [2/2]

template<class T >
template<class VEC >
void tools::mat4< T >::mul_dir_3 ( VEC &  a_dir) const
inline

Definition at line 232 of file mat4.

232 {mul_dir_3(a_dir[0],a_dir[1],a_dir[2]);}

◆ mul_mtx_rot_root()

template<class T >
void tools::mat4< T >::mul_mtx_rot_root ( const T &  a_00,
const T &  a_01,
const T &  a_02,
const T &  a_10,
const T &  a_11,
const T &  a_12,
const T &  a_20,
const T &  a_21,
const T &  a_22 
)
inline

Definition at line 394 of file mat4.

397  {
398  T* tv = pr::m_vec;
399  //pr::m_vec[0] = 00;pr::m_vec[4] = 01;pr::m_vec[ 8] = 02;pr::m_vec[12] = 03;
400  //pr::m_vec[1] = 10;pr::m_vec[5] = 11;pr::m_vec[ 9] = 12;pr::m_vec[13] = 13;
401  //pr::m_vec[2] = 20;pr::m_vec[6] = 21;pr::m_vec[10] = 22;pr::m_vec[14] = 23;
402  //pr::m_vec[3] = 30;pr::m_vec[7] = 31;pr::m_vec[11] = 32;pr::m_vec[15] = 33;
403 
404  T tv_0 = tv[0];
405  T tv_1 = tv[1];
406  T tv_2 = tv[2];
407  T tv_3 = tv[3];
408  T tv_4 = tv[4];
409  T tv_5 = tv[5];
410  T tv_6 = tv[6];
411  T tv_7 = tv[7];
412  T tv_8 = tv[8];
413  T tv_9 = tv[9];
414  T tv_10 = tv[10];
415  T tv_11 = tv[11];
416  T tv_12 = tv[12];
417  T tv_13 = tv[13];
418  T tv_14 = tv[14];
419  T tv_15 = tv[15];
420 
421  T fv_0 = a_00;
422  T fv_1 = a_10;
423  T fv_2 = a_20;
424  //T fv_3 = 0;
425 
426  T fv_4 = a_01;
427  T fv_5 = a_11;
428  T fv_6 = a_21;
429  //T fv_7 = 0;
430 
431  T fv_8 = a_02;
432  T fv_9 = a_12;
433  T fv_10 = a_22;
434  //T fv_11 = 0;
435 
436  //T fv_12 = 0;
437  //T fv_13 = 0;
438  //T fv_14 = 0;
439  //T fv_15 = 1;
440 
441  tv[0] = tv_0*fv_0+tv_4*fv_1+ tv_8*fv_2;
442  tv[1] = tv_1*fv_0+tv_5*fv_1+ tv_9*fv_2;
443  tv[2] = tv_2*fv_0+tv_6*fv_1+tv_10*fv_2;
444  tv[3] = tv_3*fv_0+tv_7*fv_1+tv_11*fv_2;
445 
446  tv[4] = tv_0*fv_4+tv_4*fv_5+ tv_8*fv_6;
447  tv[5] = tv_1*fv_4+tv_5*fv_5+ tv_9*fv_6;
448  tv[6] = tv_2*fv_4+tv_6*fv_5+tv_10*fv_6;
449  tv[7] = tv_3*fv_4+tv_7*fv_5+tv_11*fv_6;
450 
451  tv[8] = tv_0*fv_8+tv_4*fv_9+ tv_8*fv_10;
452  tv[9] = tv_1*fv_8+tv_5*fv_9+ tv_9*fv_10;
453  tv[10] = tv_2*fv_8+tv_6*fv_9+tv_10*fv_10;
454  tv[11] = tv_3*fv_8+tv_7*fv_9+tv_11*fv_10;
455 
456  tv[12] = tv_12;
457  tv[13] = tv_13;
458  tv[14] = tv_14;
459  tv[15] = tv_15;
460  }

◆ mul_rotate()

template<class T >
void tools::mat4< T >::mul_rotate ( const T &  a_x,
const T &  a_y,
const T &  a_z,
const T &  a_angle,
T(*)(T)  a_sin,
T(*)(T)  a_cos 
)
inline

Definition at line 279 of file mat4.

279  {
280  T rot[16];
281  _set_rotate(a_x,a_y,a_z,a_angle,rot,a_sin,a_cos);
282  parent::_mul_mtx(rot);
283  }

◆ mul_scale() [1/2]

template<class T >
void tools::mat4< T >::mul_scale ( const T &  a_s)
inline

Definition at line 256 of file mat4.

256  {
257  pr::m_vec[0] *= a_s;
258  pr::m_vec[1] *= a_s;
259  pr::m_vec[2] *= a_s;
260  pr::m_vec[3] *= a_s;
261 
262  pr::m_vec[4] *= a_s;
263  pr::m_vec[5] *= a_s;
264  pr::m_vec[6] *= a_s;
265  pr::m_vec[7] *= a_s;
266 
267  pr::m_vec[ 8] *= a_s;
268  pr::m_vec[ 9] *= a_s;
269  pr::m_vec[10] *= a_s;
270  pr::m_vec[11] *= a_s;
271  }

◆ mul_scale() [2/2]

template<class T >
void tools::mat4< T >::mul_scale ( const T &  a_sx,
const T &  a_sy,
const T &  a_sz 
)
inline

Definition at line 234 of file mat4.

234  {
235  // this = this * mat4_scale(a_s[x,y,z]
236  //pr::m_vec[R + C * 4];
237  //pr::m_vec[0]= 00;pr::m_vec[4] = 01;pr::m_vec[ 8] = 02;pr::m_vec[12] = 03;
238  //pr::m_vec[1]= 10;pr::m_vec[5] = 11;pr::m_vec[ 9] = 12;pr::m_vec[13] = 13;
239  //pr::m_vec[2]= 20;pr::m_vec[6] = 21;pr::m_vec[10] = 22;pr::m_vec[14] = 23;
240  //pr::m_vec[3]= 30;pr::m_vec[7] = 31;pr::m_vec[11] = 32;pr::m_vec[15] = 33;
241  pr::m_vec[0] *= a_sx;
242  pr::m_vec[1] *= a_sx;
243  pr::m_vec[2] *= a_sx;
244  pr::m_vec[3] *= a_sx;
245 
246  pr::m_vec[4] *= a_sy;
247  pr::m_vec[5] *= a_sy;
248  pr::m_vec[6] *= a_sy;
249  pr::m_vec[7] *= a_sy;
250 
251  pr::m_vec[ 8] *= a_sz;
252  pr::m_vec[ 9] *= a_sz;
253  pr::m_vec[10] *= a_sz;
254  pr::m_vec[11] *= a_sz;
255  }

◆ mul_trans_3()

template<class T >
void tools::mat4< T >::mul_trans_3 ( T &  a_x,
T &  a_y,
T &  a_z 
) const
inline

Definition at line 223 of file mat4.

223  {
224  // used in sg::healpix.
225  // a_[x,y,z] = trans_part(this) * a_[x,y,z]
226  a_x += pr::m_vec[12];
227  a_y += pr::m_vec[13];
228  a_z += pr::m_vec[14];
229  }

◆ mul_translate()

template<class T >
void tools::mat4< T >::mul_translate ( const T &  a_x,
const T &  a_y,
const T &  a_z 
)
inline

Definition at line 272 of file mat4.

272  {
273  pr::m_vec[12] = pr::m_vec[0]*a_x+pr::m_vec[4]*a_y+pr::m_vec[ 8]*a_z+pr::m_vec[12];
274  pr::m_vec[13] = pr::m_vec[1]*a_x+pr::m_vec[5]*a_y+pr::m_vec[ 9]*a_z+pr::m_vec[13];
275  pr::m_vec[14] = pr::m_vec[2]*a_x+pr::m_vec[6]*a_y+pr::m_vec[10]*a_z+pr::m_vec[14];
276  pr::m_vec[15] = pr::m_vec[3]*a_x+pr::m_vec[7]*a_y+pr::m_vec[11]*a_z+pr::m_vec[15];
277  }

◆ no_translate()

template<class T >
void tools::mat4< T >::no_translate ( )
inline

Definition at line 155 of file mat4.

155  {
156  pr::m_vec[12] = 0;
157  pr::m_vec[13] = 0;
158  pr::m_vec[14] = 0;
159  }

◆ operator=()

template<class T >
mat4& tools::mat4< T >::operator= ( const mat4< T > &  a_from)
inline

Definition at line 27 of file mat4.

27  {
28  parent::operator=(a_from);
29  return *this;
30  }

◆ set_frustum()

template<class T >
void tools::mat4< T >::set_frustum ( const T &  a_l,
const T &  a_r,
const T &  a_b,
const T &  a_t,
const T &  a_n,
const T &  a_f 
)
inline

Definition at line 97 of file mat4.

99  { //znear,zfar
100  // from man glFrustum.
101  T A = (a_r+a_l)/(a_r-a_l);
102  T B = (a_t+a_b)/(a_t-a_b);
103  T C = -(a_f+a_n)/(a_f-a_n);
104  T D = -(2*a_f*a_n)/(a_f-a_n);
105 
106  T a_00,a_01,a_02,a_03;
107  T a_10,a_11,a_12,a_13;
108  T a_20,a_21,a_22,a_23;
109  T a_30,a_31,a_32,a_33;
110  a_00 = (2*a_n)/(a_r-a_l);a_01 = 0;a_02 = A;a_03 = 0;
111  a_10 = 0;a_11 = (2*a_n)/(a_t-a_b);a_12 = B;a_13 = 0;
112  a_20 = 0;a_21 = 0;a_22 = C;a_23 = D;
113  a_30 = 0;a_31 = 0;a_32 = -1;a_33 = 0;
114  set_matrix(a_00,a_01,a_02,a_03, //1 row
115  a_10,a_11,a_12,a_13, //2 row
116  a_20,a_21,a_22,a_23, //3 row
117  a_30,a_31,a_32,a_33); //4 row
118 
119  //NOTE : Z(x,y, z,1) = C*z+D = -[(f+n)*z+2*f*n]/(f-n)
120 
121  // Z(x,y,-n,1) = -[-fn-nn+2fn]/(f-n) = -[fn-nn]/(f-n) = -n
122  // W(x,y,-n,1) = n
123  // -> Z/W(x,y,-n,1) = -1
124 
125  // Z(x,y,-2fn/(f+n),1) = 0
126  // -> Z/W = 0
127 
128  // Z(x,y,-f,1) = -[-ff-fn+2fn]/(f-n) = -[fn-ff]/(f-n) = f
129  // W(x,y,-f,1) = f
130  // -> Z/W(x,y,-f,1) = 1
131 
132  // X(x,0, z,1) = 2nx/(r-l)+z(r+l)/(r-l) = [2nx+zr+zl]/(r-l)
133  // X(r,0,-n,1) = [nr-nl]/(r-l) = n
134  // W(r,0,-n,1) = n
135  // -> X/W(r,0,-n,1) = 1
136 
137  // X(l,0,-n,1) = (2nl-n(r+l))/(r-l) = -n
138  // W(l,0,-n,1) = n
139  // -> X/W(l,0,-n,1) = -1
140 
141  // lrbt corners are in plane z=-1 at xy=+/-1.
142 
143  // eye ?
144  // eye before ? (0,0,z,1) -> (zA,zB,zC+D,-z) /W -> (-A,-B,-(C+D/z),1)
145  // z=0 -> (0,0,D=-2fn(f-n),0)
146 
147  }

◆ set_mat3()

template<class T >
template<class MAT3 >
void tools::mat4< T >::set_mat3 ( MAT3 &  a_m3)
inline

Definition at line 463 of file mat4.

463  {
464  a_m3.set_matrix(pr::m_vec[0],pr::m_vec[4],pr::m_vec[ 8], //1 row
465  pr::m_vec[1],pr::m_vec[5],pr::m_vec[ 9], //2 row
466  pr::m_vec[2],pr::m_vec[6],pr::m_vec[10]); //3 row
467  }

◆ set_matrix() [1/2]

template<class T >
void tools::mat4< T >::set_matrix ( const mat4< T > &  a_m)
inline

Definition at line 43 of file mat4.

43 {parent::set_matrix(a_m);}

◆ set_matrix() [2/2]

template<class T >
void tools::mat4< T >::set_matrix ( const T &  a_00,
const T &  a_01,
const T &  a_02,
const T &  a_03,
const T &  a_10,
const T &  a_11,
const T &  a_12,
const T &  a_13,
const T &  a_20,
const T &  a_21,
const T &  a_22,
const T &  a_23,
const T &  a_30,
const T &  a_31,
const T &  a_32,
const T &  a_33 
)
inline

Definition at line 44 of file mat4.

49  {
50  //a_<R><C>
51  //pr::m_vec[R + C * 4];
52  pr::m_vec[0] = a_00;pr::m_vec[4] = a_01;pr::m_vec[ 8] = a_02;pr::m_vec[12] = a_03;
53  pr::m_vec[1] = a_10;pr::m_vec[5] = a_11;pr::m_vec[ 9] = a_12;pr::m_vec[13] = a_13;
54  pr::m_vec[2] = a_20;pr::m_vec[6] = a_21;pr::m_vec[10] = a_22;pr::m_vec[14] = a_23;
55  pr::m_vec[3] = a_30;pr::m_vec[7] = a_31;pr::m_vec[11] = a_32;pr::m_vec[15] = a_33;
56  }

◆ set_ortho()

template<class T >
void tools::mat4< T >::set_ortho ( const T &  a_l,
const T &  a_r,
const T &  a_b,
const T &  a_t,
const T &  a_n,
const T &  a_f 
)
inline

Definition at line 64 of file mat4.

66  { //znear,zfar
67  // from man glOrtho.
68  T tx = -(a_r+a_l)/(a_r-a_l);
69  T ty = -(a_t+a_b)/(a_t-a_b);
70  T tz = -(a_f+a_n)/(a_f-a_n);
71 
72  T a_00,a_01,a_02,a_03;
73  T a_10,a_11,a_12,a_13;
74  T a_20,a_21,a_22,a_23;
75  T a_30,a_31,a_32,a_33;
76  a_00 = 2/(a_r-a_l);a_01 = 0;a_02 = 0;a_03 = tx;
77  a_10 = 0;a_11 = 2/(a_t-a_b);a_12 = 0;a_13 = ty;
78  a_20 = 0;a_21 = 0;a_22 = -2/(a_f-a_n);a_23 = tz;
79  a_30 = 0;a_31 = 0;a_32 = 0;a_33 = 1;
80  set_matrix(a_00,a_01,a_02,a_03, //1 row
81  a_10,a_11,a_12,a_13, //2 row
82  a_20,a_21,a_22,a_23, //3 row
83  a_30,a_31,a_32,a_33); //4 row
84 
85  //NOTE : Z(x,y, z,1) = -2z/(f-n)+tz = [-2z-f-n]/(f-n)
86  // W(x,y, z,1) = 1 -> Z/W = Z
87  // Z(x,y,-n,1) = -1
88  // Z(x,y,-f,1) = 1
89 
90  // Z(x,y,-(f+n)/2,1) = 0
91 
92  // X(x,0, z,1) = 2x/(r-l)+tx = [2x-r-l]/(r-l)
93  // X(r,0, z,1) = 1
94 
95  // the view direction is then (0,0,1) in the final projection.
96  }

◆ set_rotate()

template<class T >
void tools::mat4< T >::set_rotate ( const T &  a_x,
const T &  a_y,
const T &  a_z,
const T &  a_angle,
T(*)(T)  a_sin,
T(*)(T)  a_cos 
)
inline

Definition at line 61 of file mat4.

61  {
62  _set_rotate(a_x,a_y,a_z,a_angle,pr::m_vec,a_sin,a_cos);
63  }

◆ set_scale() [1/2]

template<class T >
void tools::mat4< T >::set_scale ( const T &  a_1,
const T &  a_2,
const T &  a_3 
)
inline

Definition at line 59 of file mat4.

59 {_set_scale(a_1,a_2,a_3,pr::m_vec);}

◆ set_scale() [2/2]

template<class T >
void tools::mat4< T >::set_scale ( const T &  a_s)
inline

Definition at line 58 of file mat4.

58 {_set_scale(a_s,a_s,a_s,pr::m_vec);}

◆ set_translate()

template<class T >
void tools::mat4< T >::set_translate ( const T &  a_x,
const T &  a_y,
const T &  a_z 
)
inline

Definition at line 60 of file mat4.

60 {_set_translate(a_x,a_y,a_z,pr::m_vec);}

◆ v00() [1/2]

template<class T >
const T& tools::mat4< T >::v00 ( ) const
inline

Definition at line 323 of file mat4.

323 {return pr::m_vec[0+0*4];}

◆ v00() [2/2]

template<class T >
void tools::mat4< T >::v00 ( const T &  a_value)
inline

Definition at line 303 of file mat4.

303 {pr::m_vec[0+0*4] = a_value;}

◆ v01() [1/2]

template<class T >
const T& tools::mat4< T >::v01 ( ) const
inline

Definition at line 328 of file mat4.

328 {return pr::m_vec[0+1*4];}

◆ v01() [2/2]

template<class T >
void tools::mat4< T >::v01 ( const T &  a_value)
inline

Definition at line 308 of file mat4.

308 {pr::m_vec[0+1*4] = a_value;}

◆ v02() [1/2]

template<class T >
const T& tools::mat4< T >::v02 ( ) const
inline

Definition at line 333 of file mat4.

333 {return pr::m_vec[0+2*4];}

◆ v02() [2/2]

template<class T >
void tools::mat4< T >::v02 ( const T &  a_value)
inline

Definition at line 313 of file mat4.

313 {pr::m_vec[0+2*4] = a_value;}

◆ v03() [1/2]

template<class T >
const T& tools::mat4< T >::v03 ( ) const
inline

Definition at line 338 of file mat4.

338 {return pr::m_vec[0+3*4];}

◆ v03() [2/2]

template<class T >
void tools::mat4< T >::v03 ( const T &  a_value)
inline

Definition at line 318 of file mat4.

318 {pr::m_vec[0+3*4] = a_value;}

◆ v10() [1/2]

template<class T >
const T& tools::mat4< T >::v10 ( ) const
inline

Definition at line 324 of file mat4.

324 {return pr::m_vec[1+0*4];}

◆ v10() [2/2]

template<class T >
void tools::mat4< T >::v10 ( const T &  a_value)
inline

Definition at line 304 of file mat4.

304 {pr::m_vec[1+0*4] = a_value;}

◆ v11() [1/2]

template<class T >
const T& tools::mat4< T >::v11 ( ) const
inline

Definition at line 329 of file mat4.

329 {return pr::m_vec[1+1*4];}

◆ v11() [2/2]

template<class T >
void tools::mat4< T >::v11 ( const T &  a_value)
inline

Definition at line 309 of file mat4.

309 {pr::m_vec[1+1*4] = a_value;}

◆ v12() [1/2]

template<class T >
const T& tools::mat4< T >::v12 ( ) const
inline

Definition at line 334 of file mat4.

334 {return pr::m_vec[1+2*4];}

◆ v12() [2/2]

template<class T >
void tools::mat4< T >::v12 ( const T &  a_value)
inline

Definition at line 314 of file mat4.

314 {pr::m_vec[1+2*4] = a_value;}

◆ v13() [1/2]

template<class T >
const T& tools::mat4< T >::v13 ( ) const
inline

Definition at line 339 of file mat4.

339 {return pr::m_vec[1+3*4];}

◆ v13() [2/2]

template<class T >
void tools::mat4< T >::v13 ( const T &  a_value)
inline

Definition at line 319 of file mat4.

319 {pr::m_vec[1+3*4] = a_value;}

◆ v20() [1/2]

template<class T >
const T& tools::mat4< T >::v20 ( ) const
inline

Definition at line 325 of file mat4.

325 {return pr::m_vec[2+0*4];}

◆ v20() [2/2]

template<class T >
void tools::mat4< T >::v20 ( const T &  a_value)
inline

Definition at line 305 of file mat4.

305 {pr::m_vec[2+0*4] = a_value;}

◆ v21() [1/2]

template<class T >
const T& tools::mat4< T >::v21 ( ) const
inline

Definition at line 330 of file mat4.

330 {return pr::m_vec[2+1*4];}

◆ v21() [2/2]

template<class T >
void tools::mat4< T >::v21 ( const T &  a_value)
inline

Definition at line 310 of file mat4.

310 {pr::m_vec[2+1*4] = a_value;}

◆ v22() [1/2]

template<class T >
const T& tools::mat4< T >::v22 ( ) const
inline

Definition at line 335 of file mat4.

335 {return pr::m_vec[2+2*4];}

◆ v22() [2/2]

template<class T >
void tools::mat4< T >::v22 ( const T &  a_value)
inline

Definition at line 315 of file mat4.

315 {pr::m_vec[2+2*4] = a_value;}

◆ v23() [1/2]

template<class T >
const T& tools::mat4< T >::v23 ( ) const
inline

Definition at line 340 of file mat4.

340 {return pr::m_vec[2+3*4];}

◆ v23() [2/2]

template<class T >
void tools::mat4< T >::v23 ( const T &  a_value)
inline

Definition at line 320 of file mat4.

320 {pr::m_vec[2+3*4] = a_value;}

◆ v30() [1/2]

template<class T >
const T& tools::mat4< T >::v30 ( ) const
inline

Definition at line 326 of file mat4.

326 {return pr::m_vec[3+0*4];}

◆ v30() [2/2]

template<class T >
void tools::mat4< T >::v30 ( const T &  a_value)
inline

Definition at line 306 of file mat4.

306 {pr::m_vec[3+0*4] = a_value;}

◆ v31() [1/2]

template<class T >
const T& tools::mat4< T >::v31 ( ) const
inline

Definition at line 331 of file mat4.

331 {return pr::m_vec[3+1*4];}

◆ v31() [2/2]

template<class T >
void tools::mat4< T >::v31 ( const T &  a_value)
inline

Definition at line 311 of file mat4.

311 {pr::m_vec[3+1*4] = a_value;}

◆ v32() [1/2]

template<class T >
const T& tools::mat4< T >::v32 ( ) const
inline

Definition at line 336 of file mat4.

336 {return pr::m_vec[3+2*4];}

◆ v32() [2/2]

template<class T >
void tools::mat4< T >::v32 ( const T &  a_value)
inline

Definition at line 316 of file mat4.

316 {pr::m_vec[3+2*4] = a_value;}

◆ v33() [1/2]

template<class T >
const T& tools::mat4< T >::v33 ( ) const
inline

Definition at line 341 of file mat4.

341 {return pr::m_vec[3+3*4];}

◆ v33() [2/2]

template<class T >
void tools::mat4< T >::v33 ( const T &  a_value)
inline

Definition at line 321 of file mat4.

321 {pr::m_vec[3+3*4] = a_value;}

The documentation for this class was generated from the following file:
tools::mat< T, 4 >::m_vec
T m_vec[D *D]
Definition: mat:85
tools::mat4::set_matrix
void set_matrix(const mat4< T > &a_m)
Definition: mat4:43
tools::mat4::mul_dir_3
void mul_dir_3(T &a_x, T &a_y, T &a_z) const
Definition: mat4:211
tools::set_matrix
void set_matrix(MATRIX &a_matrix, const std::string &a_fmt)
Definition: sprintf:100
tools::mat4::_set_translate
static void _set_translate(const T &a_x, const T &a_y, const T &a_z, T v[])
Definition: mat4:344
tools::mat4::_set_scale
static void _set_scale(const T &a_1, const T &a_2, const T &a_3, T v[])
Definition: mat4:351
tools::mat< T, 4 >::operator=
mat & operator=(const mat &a_from)
Definition: mat:64
tools::mat4::_set_rotate
static void _set_rotate(const T &a_x, const T &a_y, const T &a_z, const T &a_angle, T v[], T(*a_sin)(T), T(*a_cos)(T))
Definition: mat4:358