]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' |
2 | 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'> | |
3 | <html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'> | |
4 | <head> | |
5 | <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/> | |
6 | <title>mat_traits</title> | |
7 | <link href='reno.css' type='text/css' rel='stylesheet'/> | |
8 | </head> | |
9 | <body> | |
10 | <div class="body-0"> | |
11 | <div class="body-1"> | |
12 | <div class="body-2"> | |
13 | <div> | |
14 | <h1>QVM: Quaternions, Vectors, Matrices</h1> | |
15 | </div> | |
16 | <!-- Copyright (c) 2008-2016 Emil Dotchevski and Reverge Studios, Inc. --> | |
17 | <!-- Distributed under the Boost Software License, Version 1.0. (See accompanying --> | |
18 | <!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) --> | |
19 | <div class="RenoIncludeDIV"><div class="RenoAutoDIV"><h3>mat_traits</h3> | |
20 | </div> | |
21 | <div class="RenoIncludeDIV"><p><span class="RenoEscape">#<!--<wiki>`#</wiki>--></span>include <<span class="RenoLink"><a href="boost_qvm_mat_traits_hpp.html">boost/qvm/mat_traits.hpp</a></span>></p> | |
22 | <pre>namespace boost | |
23 | { | |
24 | namespace <span class="RenoLink"><a href="qvm.html">qvm</a></span> | |
25 | { | |
26 | <span class="RenoIncludeSPAN"> template <class M> | |
27 | struct <span class="RenoLink">mat_traits</span> | |
28 | { | |
29 | /*main template members unspecified*/ | |
30 | }; | |
31 | ||
32 | /* | |
33 | User-defined (possibly partial) specializations: | |
34 | ||
35 | template <> | |
36 | struct <span class="RenoLink">mat_traits</span><M> | |
37 | { | |
38 | <span class="RenoIncludeSPAN"> static int const <span class="RenoLink"><a href="mat_traits_Matrix_rows.html">rows</a></span> = /*user-defined*/;</span> | |
39 | <span class="RenoIncludeSPAN"> static int const <span class="RenoLink"><a href="mat_traits_Matrix_cols.html">cols</a></span> = /*user-defined*/;</span> | |
40 | <span class="RenoIncludeSPAN"> typedef /*user-defined*/ <span class="RenoLink"><a href="mat_traits_M_scalar_type.html">scalar_type</a></span>;</span> | |
41 | ||
42 | <span class="RenoIncludeSPAN"> template <int R,int C> static inline <span class="RenoLink"><a href="mat_traits_M_scalar_type.html">scalar_type</a></span> <span class="RenoLink"><a href="mat_traits_M_read_element.html">read_element</a></span>( Matrix const & m );</span> | |
43 | <span class="RenoIncludeSPAN"> template <int R,int C> static inline <span class="RenoLink"><a href="mat_traits_M_scalar_type.html">scalar_type</a></span> & <span class="RenoLink"><a href="mat_traits_M_write_element.html">write_element</a></span>( Matrix & m );</span> | |
44 | ||
45 | <span class="RenoIncludeSPAN"> static inline <span class="RenoLink"><a href="mat_traits_M_scalar_type.html">scalar_type</a></span> <span class="RenoLink"><a href="mat_traits_M_read_element_idx.html">read_element_idx</a></span>( int r, int c, Matrix const & m );</span> | |
46 | <span class="RenoIncludeSPAN"> static inline <span class="RenoLink"><a href="mat_traits_M_scalar_type.html">scalar_type</a></span> & <span class="RenoLink"><a href="mat_traits_M_write_element_idx.html">write_element_idx</a></span>( int r, int c, Matrix & m );</span> | |
47 | }; | |
48 | */</span> | |
49 | } | |
50 | }</pre> | |
51 | </div><p>The <i><span class="RenoLink">mat_traits</span></i> template must be specialized for (user-defined) matrix types in order to enable vector and matrix operations defined in Boost QVM headers for objects of those types.</p> | |
52 | <blockquote><p>Note: <i>matrix types are not required to be copyable.</i></p></blockquote> | |
53 | <p>The main <i><span class="RenoLink">mat_traits</span></i> template members are not specified. Valid specializations are required to define the following members:</p> | |
54 | <div><ul><li> <i><span class="RenoLink"><a href="mat_traits_Matrix_rows.html">rows</a></span></i>: the expression <i><span class="RenoLink">mat_traits</span><Matrix>::<span class="RenoLink"><a href="mat_traits_Matrix_rows.html">rows</a></span></i> must evaluate to a compile-time integer constant greater than 0 that specifies the number of rows in a matrix.</li> | |
55 | <li> <i><span class="RenoLink"><a href="mat_traits_Matrix_cols.html">cols</a></span></i> must evaluate to a compile-time integer constant greater than 0 that specifies the number of columns in a matrix.</li> | |
56 | <li> <i><span class="RenoLink"><a href="mat_traits_M_scalar_type.html">scalar_type</a></span></i>: the expression <i><span class="RenoLink">mat_traits</span><Matrix>::<span class="RenoLink"><a href="mat_traits_M_scalar_type.html">scalar_type</a></span></i> must be a value type which satisfies the <span class="RenoLink"><a href="scalar_requirements.html">scalar requirements</a></span>.</li> | |
57 | </ul></div> | |
58 | <p>In addition, valid specializations of the <i><span class="RenoLink">mat_traits</span></i> template may define the following access functions as static members, where <i>m</i> is an object of type <i>Matrix</i>, <i>R</i> and <i>C</i> are compile-time integer constants, and <i>r</i> and <i>c</i> are variables of type <i>int</i>:</p> | |
59 | <div><ul><li> <i><span class="RenoLink"><a href="mat_traits_M_read_element.html">read_element</a></span></i>: the expression <i><span class="RenoLink">mat_traits</span><Matrix>::<span class="RenoLink"><a href="mat_traits_M_read_element.html">read_element</a></span><R,C>(m)</i> returns either a copy of or a const reference to the element at row <i>R</i> and column <i>C</i> of <i>m</i>.</li> | |
60 | <li> <i><span class="RenoLink"><a href="mat_traits_M_write_element.html">write_element</a></span></i>: the expression <i><span class="RenoLink">mat_traits</span><Matrix>::<span class="RenoLink"><a href="mat_traits_M_write_element.html">write_element</a></span><R,C>(m)</i> returns mutable reference to the element at row <i>R</i> and column <i>C</i> of <i>m</i>.</li> | |
61 | <li> <i><span class="RenoLink"><a href="mat_traits_M_read_element_idx.html">read_element_idx</a></span></i>: the expression <i><span class="RenoLink">mat_traits</span><Matrix>::<span class="RenoLink"><a href="mat_traits_M_read_element_idx.html">read_element_idx</a></span>(r,c,m)</i> returns either a copy of or a const reference to the element at row <i>r</i> and column <i>c</i> of <i>m</i>.</li> | |
62 | <li> <i><span class="RenoLink"><a href="mat_traits_M_write_element_idx.html">write_element_idx</a></span></i>: the expression <i><span class="RenoLink">mat_traits</span><Matrix>::<span class="RenoLink"><a href="mat_traits_M_write_element_idx.html">write_element_idx</a></span>(r,c,m)</i> returns mutable reference to the element at row <i>r</i> and column <i>c</i> of <i>m</i>.</li> | |
63 | </ul></div> | |
64 | <p>It is illegal to call any of the above functions unless <i><span class="RenoLink"><a href="is_mat.html">is_mat</a></span><Matrix>::value</i> is <i>true</i>. Even then, matrix types are allowed to define only a subset of the access functions. The general requirements are:</p> | |
65 | <div><ul><li> At least one of <i><span class="RenoLink"><a href="mat_traits_M_read_element.html">read_element</a></span></i> or <i><span class="RenoLink"><a href="mat_traits_M_write_element.html">write_element</a></span></i> must be defined;</li> | |
66 | <li> If <i><span class="RenoLink"><a href="mat_traits_M_read_element_idx.html">read_element_idx</a></span></i> is defined, <i><span class="RenoLink"><a href="mat_traits_M_read_element.html">read_element</a></span></i> must also be defined;</li> | |
67 | <li> If <i><span class="RenoLink"><a href="mat_traits_M_write_element_idx.html">write_element_idx</a></span></i> is defined, <i><span class="RenoLink"><a href="mat_traits_M_write_element.html">write_element</a></span></i> must also be defined.</li> | |
68 | </ul></div> | |
69 | <p>Below is an example of a user-defined 3x3 matrix type, and its corresponding specialization of the <i><span class="RenoLink">mat_traits</span></i> template:</p> | |
70 | <div class="RenoIncludeDIV"><pre>#include <<span class="RenoLink"><a href="boost_qvm_mat_traits_hpp.html">boost/qvm/mat_traits.hpp</a></span>> | |
71 | ||
72 | struct float33 { float a[3][3]; }; | |
73 | ||
74 | namespace boost | |
75 | { | |
76 | namespace <span class="RenoLink"><a href="qvm.html">qvm</a></span> | |
77 | { | |
78 | template <> | |
79 | struct <span class="RenoLink">mat_traits</span><float33> | |
80 | { | |
81 | static int const <span class="RenoLink"><a href="mat_traits_Matrix_rows.html">rows</a></span>=3; | |
82 | static int const <span class="RenoLink"><a href="mat_traits_Matrix_cols.html">cols</a></span>=3; | |
83 | typedef float <span class="RenoLink"><a href="mat_traits_M_scalar_type.html">scalar_type</a></span>; | |
84 | ||
85 | template <int R,int C> static inline <span class="RenoLink"><a href="mat_traits_M_scalar_type.html">scalar_type</a></span> & <span class="RenoLink"><a href="mat_traits_M_write_element.html">write_element</a></span>( float33 & m ) { return m.a[R][C]; } | |
86 | template <int R,int C> static inline <span class="RenoLink"><a href="mat_traits_M_scalar_type.html">scalar_type</a></span> <span class="RenoLink"><a href="mat_traits_M_read_element.html">read_element</a></span>( float33 const & m ) { return m.a[R][C]; } | |
87 | ||
88 | static inline <span class="RenoLink"><a href="mat_traits_M_scalar_type.html">scalar_type</a></span> & <span class="RenoLink"><a href="mat_traits_M_write_element_idx.html">write_element_idx</a></span>( int r, int c, float33 & m ) { return m.a[r][c]; } | |
89 | static inline <span class="RenoLink"><a href="mat_traits_M_scalar_type.html">scalar_type</a></span> <span class="RenoLink"><a href="mat_traits_M_read_element_idx.html">read_element_idx</a></span>( int r, int c, float33 const & m ) { return m.a[r][c]; } | |
90 | }; | |
91 | } | |
92 | }</pre> | |
93 | </div></div><div class="RenoAutoDIV"><div class="RenoHR"><hr/></div> | |
94 | See also: <span class="RenoPageList"><a href="assign_mat_mat_.html">assign(mat,mat)</a> | <a href="boost_qvm_mat_traits_hpp.html">boost/qvm/mat_traits.hpp</a> | <a href="boost_qvm_mat_traits_array_hpp.html">boost/qvm/mat_traits_array.hpp</a> | <a href="cmp_mat_mat_.html">cmp(mat,mat)</a> | <a href="convert_to_mat_.html">convert_to(mat)</a> | <a href="convert_to_quat_.html">convert_to(quat)</a> | <a href="deduce_mat.html">deduce_mat</a> | <a href="deduce_mat2.html">deduce_mat2</a> | <a href="determinant.html">determinant</a> | <a href="inverse_mat_.html">inverse(mat)</a> | <a href="is_mat.html">is_mat</a> | <a href="mat.html">mat</a> | <a href="mat_index_read.html">mat_index_read</a> | <a href="mat_index_write.html">mat_index_write</a> | <a href="mat_traits_M_read_element.html">mat_traits<M>::read_element</a> | <a href="mat_traits_M_read_element_idx.html">mat_traits<M>::read_element_idx</a> | <a href="mat_traits_M_scalar_type.html">mat_traits<M>::scalar_type</a> | <a href="mat_traits_M_write_element.html">mat_traits<M>::write_element</a> | <a href="mat_traits_M_write_element_idx.html">mat_traits<M>::write_element_idx</a> | <a href="mat_traits_Matrix_cols.html">mat_traits<Matrix>::cols</a> | <a href="mat_traits_Matrix_rows.html">mat_traits<Matrix>::rows</a> | <a href="operator_not_eq_mat_mat_.html">operator!=(mat,mat)</a> | <a href="operator_times_mat_mat_.html">operator*(mat,mat)</a> | <a href="operator_times_mat_vec_.html">operator*(mat,vec)</a> | <a href="operator_times_vec_mat_.html">operator*(vec,mat)</a> | <a href="operator_mul_eq_mat_mat_.html">operator*=(mat,mat)</a> | <a href="operator_plus_mat_mat_.html">operator+(mat,mat)</a> | <a href="operator_add_mat_mat_.html">operator+=(mat,mat)</a> | <a href="operator_minus_mat_mat_.html">operator-(mat,mat)</a> | <a href="operator_sub_eq_mat_mat_.html">operator-=(mat,mat)</a> | <a href="operator_eq_mat_mat_.html">operator==(mat,mat)</a> | <a href="rotate_mat_vec_scalar_.html">rotate(mat,vec,scalar)</a> | <a href="rotate_x_mat_scalar_.html">rotate_x(mat,scalar)</a> | <a href="rotate_y_mat_scalar_.html">rotate_y(mat,scalar)</a> | <a href="rotate_z_mat_scalar_.html">rotate_z(mat,scalar)</a> | <a href="SFINAE_enable_if.html">SFINAE/enable_if</a> | <a href="scalar.html">scalar</a> | <a href="set_identity_mat_.html">set_identity(mat)</a> | <a href="set_rot_mat_vec_scalar_.html">set_rot(mat,vec,scalar)</a> | <a href="set_rotx_mat_scalar_.html">set_rotx(mat,scalar)</a> | <a href="set_roty_mat_scalar_.html">set_roty(mat,scalar)</a> | <a href="set_rotz_mat_scalar_.html">set_rotz(mat,scalar)</a> | <a href="set_zero_mat_.html">set_zero(mat)</a> | <a href="transform_point.html">transform_point</a> | <a href="transform_vector.html">transform_vector</a> | <a href="translation.html">translation</a> | <a href="view_proxy.html">View Proxy</a></span> | |
95 | </div> | |
96 | <!-- Copyright (c) 2008-2016 Emil Dotchevski and Reverge Studios, Inc. --> | |
97 | <!-- Distributed under the Boost Software License, Version 1.0. (See accompanying --> | |
98 | <!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) --> | |
99 | <div id="footer"> | |
100 | <p> | |
101 | <a class="logo" href="http://jigsaw.w3.org/css-validator/check/referer"><img class="logo_pic" src="valid-css.png" alt="Valid CSS" height="31" width="88"/></a> | |
102 | <a class="logo" href="http://validator.w3.org/check?uri=referer"><img class="logo_pic" src="valid-xhtml.png" alt="Valid XHTML 1.0" height="31" width="88"/></a> | |
103 | <small>Copyright (c) 2008-2016 by Emil Dotchevski and Reverge Studios, Inc.<br/> | |
104 | Distributed under the <a href="http://www.boost.org/LICENSE_1_0.txt">Boost Software License, Version 1.0</a>.</small> | |
105 | </p> | |
106 | </div> | |
107 | </div> | |
108 | </div> | |
109 | </div> | |
110 | </body> | |
111 | </html> |