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'
>
5 <meta http-equiv='Content-Type' content='text/html; charset=utf-
8'
/>
6 <title>quat_traits
</title>
7 <link href='reno.css' type='text/css' rel='stylesheet'
/>
14 <h1>QVM: Quaternions, Vectors, Matrices
</h1>
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>quat_traits
</h3>
21 <div class=
"RenoIncludeDIV"><p><span class=
"RenoEscape">#<!--<wiki>`#</wiki>--></span>include
<<span class=
"RenoLink"><a href=
"boost_qvm_quat_traits_hpp.html">boost/qvm/quat_traits.hpp
</a></span>></p>
26 <span class=
"RenoLink"><a href=
"qvm.html">qvm
</a></span>
28 <span class=
"RenoIncludeSPAN"> template
<class Q
>
29 struct
<span class=
"RenoLink">quat_traits
</span>
31 /*main template members unspecified*/
35 User-defined (possibly partial) specializations:
38 struct
<span class=
"RenoLink">quat_traits
</span><Q
>
40 <span class=
"RenoIncludeSPAN"> typedef /*user-defined*/
<span class=
"RenoLink"><a href=
"quat_traits_Q_scalar_type.html">scalar_type
</a></span>;
</span>
42 <span class=
"RenoIncludeSPAN"> template
<int I
> static inline
<span class=
"RenoLink"><a href=
"quat_traits_Q_scalar_type.html">scalar_type
</a></span> <span class=
"RenoLink"><a href=
"quat_traits_Q_read_element.html">read_element
</a></span>( Quaternion const
& q );
</span>
43 <span class=
"RenoIncludeSPAN"> template
<int I
> static inline
<span class=
"RenoLink"><a href=
"quat_traits_Q_scalar_type.html">scalar_type
</a></span> & <span class=
"RenoLink"><a href=
"quat_traits_Q_write_element.html">write_element
</a></span>( Quaternion
& q );
</span>
48 </div><p>The
<i><span class=
"RenoLink">quat_traits
</span></i> template must be specialized for (user-defined) quaternion types in order to enable quaternion operations defined in Boost QVM headers for objects of those types.
</p>
49 <p><i>Note: quaternion types are not required to be copyable.
</i></p>
50 <p>The main
<i><span class=
"RenoLink">quat_traits
</span></i> template members are not specified. Valid specializations are required to define the following members:
</p>
51 <div><ul><li> <i><span class=
"RenoLink"><a href=
"quat_traits_Q_scalar_type.html">scalar_type
</a></span></i>: the expression
<i><span class=
"RenoLink">quat_traits
</span><Quaternion
>::
<span class=
"RenoLink"><a href=
"quat_traits_Q_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>
53 <p>In addition, valid specializations of the
<i><span class=
"RenoLink">quat_traits
</span></i> template must define at least one of the following access functions as static members, where
<i>q
</i> is an object of type Quaternion, and
<i>I
</i> is compile-time integer constant:
</p>
54 <div><ul><li> <i><span class=
"RenoLink"><a href=
"quat_traits_Q_read_element.html">read_element
</a></span></i>: the expression
<i><span class=
"RenoLink">quat_traits
</span><Quaternion
>::
<span class=
"RenoLink"><a href=
"quat_traits_Q_read_element.html">read_element
</a></span><I
>(q)
</i> returns either a copy of or a const reference to the
<i>I
</i>-th element of
<i>q
</i>.
</li>
55 <li> <i><span class=
"RenoLink"><a href=
"quat_traits_Q_write_element.html">write_element
</a></span></i>: the expression
<i><span class=
"RenoLink">quat_traits
</span><Quaternion
>::
<span class=
"RenoLink"><a href=
"quat_traits_Q_write_element.html">write_element
</a></span><I
>(q)
</i> returns mutable reference to the
<i>I
</i>-th element of
<i>q
</i>.
</li>
57 <div class=
"RenoIncludeDIV"><p><b>Note:
</b> For the quaternion
<i>a + bi + cj + dk
</i>, the elements are assumed to be in the following order:
<i>a
</i>,
<i>b
</i>,
<i>c
</i>,
<i>d
</i>; that is,
<i>I
</i>=
<i>0</i>/
<i>1</i>/
<i>2</i>/
<i>3</i> would access
<i>a
</i>/
<i>b
</i>/
<i>c
</i>/
<i>d
</i>.
</p>
58 </div><p>It is illegal to call any of the above functions unless
<i><span class=
"RenoLink"><a href=
"is_quat.html">is_quat
</a></span><Quaternion
>::value
</i>' is true. Even then, quaternion types are allowed to define only a subset of the access functions.
</p>
59 <p>Below is an example of a user-defined quaternion type, and its corresponding specialization of the
<i><span class=
"RenoLink">quat_traits
</span></i> template:
</p>
60 <div class=
"RenoIncludeDIV"><pre>#include
<<span class=
"RenoLink"><a href=
"boost_qvm_quat_traits_hpp.html">boost/qvm/quat_traits.hpp
</a></span>>
62 struct fquat { float a[
4]; };
66 namespace
<span class=
"RenoLink"><a href=
"qvm.html">qvm
</a></span>
70 <span class=
"RenoLink">quat_traits
</span><fquat
>
72 typedef float
<span class=
"RenoLink"><a href=
"quat_traits_Q_scalar_type.html">scalar_type
</a></span>;
74 template
<int I
> static inline
<span class=
"RenoLink"><a href=
"quat_traits_Q_scalar_type.html">scalar_type
</a></span> & <span class=
"RenoLink"><a href=
"quat_traits_Q_write_element.html">write_element
</a></span>( fquat
& q ) { return q.a[I]; }
75 template
<int I
> static inline
<span class=
"RenoLink"><a href=
"quat_traits_Q_scalar_type.html">scalar_type
</a></span> <span class=
"RenoLink"><a href=
"quat_traits_Q_read_element.html">read_element
</a></span>( fquat const
& q ) { return q.a[I]; }
79 </div></div><div class=
"RenoAutoDIV"><div class=
"RenoHR"><hr/></div>
80 See also:
<span class=
"RenoPageList"><a href=
"boost_qvm_quat_traits_hpp.html">boost/qvm/quat_traits.hpp
</a> |
<a href=
"boost_qvm_quat_traits_array_hpp.html">boost/qvm/quat_traits_array.hpp
</a> |
<a href=
"is_quat.html">is_quat
</a> |
<a href=
"mag_quat_.html">mag(quat)
</a> |
<a href=
"mag_sqr_quat_.html">mag_sqr(quat)
</a> |
<a href=
"normalize_quat_.html">normalize(quat)
</a> |
<a href=
"quat.html">quat
</a> |
<a href=
"quat_traits_Q_read_element.html">quat_traits
<Q
>::read_element
</a> |
<a href=
"quat_traits_Q_scalar_type.html">quat_traits
<Q
>::scalar_type
</a> |
<a href=
"quat_traits_Q_write_element.html">quat_traits
<Q
>::write_element
</a> |
<a href=
"rotate_quat_vec_scalar_.html">rotate(quat,vec,scalar)
</a> |
<a href=
"rotate_x_quat_scalar_.html">rotate_x(quat,scalar)
</a> |
<a href=
"rotate_y_quat_scalar_.html">rotate_y(quat,scalar)
</a> |
<a href=
"rotate_z_quat_scalar_.html">rotate_z(quat,scalar)
</a> |
<a href=
"scalar.html">scalar
</a> |
<a href=
"set_identity_quat_.html">set_identity(quat)
</a> |
<a href=
"set_rotx_quat_scalar_.html">set_rotx(quat,scalar)
</a> |
<a href=
"set_roty_quat_scalar_.html">set_roty(quat,scalar)
</a> |
<a href=
"set_rotz_quat_scalar_.html">set_rotz(quat,scalar)
</a> |
<a href=
"set_zero_quat_.html">set_zero(quat)
</a> |
<a href=
"view_proxy.html">View Proxy
</a></span>
82 <!-- Copyright (c) 2008-2016 Emil Dotchevski and Reverge Studios, Inc. -->
83 <!-- Distributed under the Boost Software License, Version 1.0. (See accompanying -->
84 <!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -->
87 <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>
88 <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>
89 <small>Copyright (c)
2008-
2016 by Emil Dotchevski and Reverge Studios, Inc.
<br/>
90 Distributed under the
<a href=
"http://www.boost.org/LICENSE_1_0.txt">Boost Software License, Version
1.0</a>.
</small>