quaternion_promotions.h

Go to the documentation of this file.
00001 /* -*- C++ -*- ------------------------------------------------------------
00002  
00003 Copyright (c) 2007 Jesse Anders and Demian Nave http://cmldev.net/
00004 
00005 The Configurable Math Library (CML) is distributed under the terms of the
00006 Boost Software License, v1.0 (see cml/LICENSE for details).
00007 
00008  *-----------------------------------------------------------------------*/
00013 #ifndef quaternion_promotions_h
00014 #define quaternion_promotions_h
00015 
00016 #include <cml/et/scalar_promotions.h>
00017 #include <cml/vector/vector_promotions.h>
00018 
00019 namespace cml {
00020 namespace et {
00021 
00022 /* Default quaternion type promotion templates. */
00023 template<class LeftT, class RightT> struct QuaternionPromote;
00024 
00026 template<typename E1, class AT1, typename E2, class AT2, class OT, class CT>
00027 struct QuaternionPromote<
00028     cml::quaternion<E1,AT1,OT,CT>,
00029     cml::quaternion<E2,AT2,OT,CT>
00030 >
00031 {
00032     /* The deduced vector type: */
00033     typedef typename VectorPromote<
00034         typename cml::quaternion<E1,AT1,OT,CT>::vector_type,
00035         typename cml::quaternion<E2,AT2,OT,CT>::vector_type
00036         >::type promoted_vector;
00037 
00038     /* The deduced element and storage types: */
00039     typedef typename promoted_vector::value_type value_type;
00040     typedef typename promoted_vector::storage_type storage_type;
00041 
00042     /* The deduced quaternion result type: */
00043     typedef cml::quaternion<value_type,storage_type,OT,CT> type;
00044 
00045     /* The temporary type: */
00046     typedef typename type::temporary_type temporary_type;
00047 };
00048 
00055 template < class Quat1_T, class Quat2_T >
00056 struct QuaternionPromote2
00057 {
00058     typedef typename QuaternionPromote<
00059         typename Quat1_T::temporary_type, typename Quat2_T::temporary_type
00060     >::temporary_type temporary_type;
00061     typedef typename temporary_type::value_type value_type;
00062 };
00063 
00065 template < class Quat1_T, class Quat2_T, class Quat3_T >
00066 struct QuaternionPromote3
00067 {
00068     typedef typename QuaternionPromote<
00069         typename Quat1_T::temporary_type,
00070         typename QuaternionPromote<
00071             typename Quat2_T::temporary_type, typename Quat3_T::temporary_type
00072         >::temporary_type
00073     >::temporary_type temporary_type;
00074     typedef typename temporary_type::value_type value_type;
00075 };
00076 
00078 template < class Quat1_T, class Quat2_T, class Quat3_T, class Quat4_T >
00079 struct QuaternionPromote4
00080 {
00081     typedef typename QuaternionPromote<
00082         typename Quat1_T::temporary_type,
00083         typename QuaternionPromote<
00084             typename Quat2_T::temporary_type,
00085             typename QuaternionPromote<
00086                 typename Quat3_T::temporary_type,
00087                 typename Quat4_T::temporary_type
00088             >::temporary_type
00089         >::temporary_type
00090     >::temporary_type temporary_type;
00091     typedef typename temporary_type::value_type value_type;
00092 };
00093 
00095 template<typename E, class AT, class OT, class CT, typename S>
00096 struct QuaternionPromote<cml::quaternion<E,AT,OT,CT>, S>
00097 {
00098     /* The deduced vector type: */
00099     typedef typename VectorPromote<
00100         typename quaternion<E,AT,OT,CT>::vector_type, S
00101         >::type promoted_vector;
00102 
00103     /* The deduced element and storage types: */
00104     typedef typename promoted_vector::value_type value_type;
00105     typedef typename promoted_vector::storage_type storage_type;
00106 
00107     /* The deduced quaternion result type: */
00108     typedef cml::quaternion<value_type,storage_type,OT,CT> type;
00109 
00110     /* The temporary type: */
00111     typedef typename type::temporary_type temporary_type;
00112 };
00113 
00115 template<class S, typename E, class AT, class OT, class CT>
00116 struct QuaternionPromote<S, cml::quaternion<E,AT,OT,CT> >
00117 {
00118     /* The deduced vector type: */
00119     typedef typename VectorPromote<
00120         S, typename quaternion<E,AT,OT,CT>::vector_type
00121         >::type promoted_vector;
00122 
00123     /* The deduced element and storage types: */
00124     typedef typename promoted_vector::value_type value_type;
00125     typedef typename promoted_vector::storage_type storage_type;
00126 
00127     /* The deduced quaternion result type: */
00128     typedef cml::quaternion<value_type,storage_type,OT,CT> type;
00129 
00130     /* The temporary type: */
00131     typedef typename type::temporary_type temporary_type;
00132 };
00133 
00134 } // namespace et
00135 } // namespace cml
00136 
00137 #endif
00138 
00139 // -------------------------------------------------------------------------
00140 // vim:ft=cpp

Generated on Sat Jul 18 19:35:32 2009 for CML 1.0 by  doxygen 1.5.9