123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627 |
- #ifndef BOOST_QVM_GEN_VEC_OPERATIONS2_HPP_INCLUDED
- #define BOOST_QVM_GEN_VEC_OPERATIONS2_HPP_INCLUDED
- /// Copyright (c) 2008-2021 Emil Dotchevski and Reverge Studios, Inc.
- /// Distributed under the Boost Software License, Version 1.0. (See accompanying
- /// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
- /// This file was generated by a program. Do not edit manually.
- #include <boost/qvm/deduce_scalar.hpp>
- #include <boost/qvm/deduce_vec.hpp>
- #include <boost/qvm/error.hpp>
- #include <boost/qvm/gen/vec_assign2.hpp>
- #include <boost/qvm/math.hpp>
- #include <boost/qvm/static_assert.hpp>
- #include <boost/qvm/throw_exception.hpp>
- namespace boost { namespace qvm {
- template <class A,class B>
- BOOST_QVM_INLINE_OPERATIONS
- typename lazy_enable_if_c<
- vec_traits<A>::dim==2 && vec_traits<B>::dim==2,
- deduce_vec2<A,B,2> >::type
- operator+( A const & a, B const & b )
- {
- typedef typename deduce_vec2<A,B,2>::type R;
- BOOST_QVM_STATIC_ASSERT(vec_traits<R>::dim==2);
- R r;
- vec_traits<R>::template write_element<0>(r)=vec_traits<A>::template read_element<0>(a)+vec_traits<B>::template read_element<0>(b);
- vec_traits<R>::template write_element<1>(r)=vec_traits<A>::template read_element<1>(a)+vec_traits<B>::template read_element<1>(b);
- return r;
- }
- namespace
- sfinae
- {
- using ::boost::qvm::operator+;
- }
- namespace
- qvm_detail
- {
- template <int D>
- struct plus_vv_defined;
- template <>
- struct
- plus_vv_defined<2>
- {
- static bool const value=true;
- };
- }
- template <class A,class B>
- BOOST_QVM_INLINE_OPERATIONS
- typename lazy_enable_if_c<
- vec_traits<A>::dim==2 && vec_traits<B>::dim==2,
- deduce_vec2<A,B,2> >::type
- operator-( A const & a, B const & b )
- {
- typedef typename deduce_vec2<A,B,2>::type R;
- BOOST_QVM_STATIC_ASSERT(vec_traits<R>::dim==2);
- R r;
- vec_traits<R>::template write_element<0>(r)=vec_traits<A>::template read_element<0>(a)-vec_traits<B>::template read_element<0>(b);
- vec_traits<R>::template write_element<1>(r)=vec_traits<A>::template read_element<1>(a)-vec_traits<B>::template read_element<1>(b);
- return r;
- }
- namespace
- sfinae
- {
- using ::boost::qvm::operator-;
- }
- namespace
- qvm_detail
- {
- template <int D>
- struct minus_vv_defined;
- template <>
- struct
- minus_vv_defined<2>
- {
- static bool const value=true;
- };
- }
- template <class A,class B>
- BOOST_QVM_INLINE_OPERATIONS
- typename enable_if_c<
- vec_traits<A>::dim==2 && vec_traits<B>::dim==2,
- A &>::type
- operator+=( A & a, B const & b )
- {
- vec_traits<A>::template write_element<0>(a)+=vec_traits<B>::template read_element<0>(b);
- vec_traits<A>::template write_element<1>(a)+=vec_traits<B>::template read_element<1>(b);
- return a;
- }
- namespace
- sfinae
- {
- using ::boost::qvm::operator+=;
- }
- namespace
- qvm_detail
- {
- template <int D>
- struct plus_eq_vv_defined;
- template <>
- struct
- plus_eq_vv_defined<2>
- {
- static bool const value=true;
- };
- }
- template <class A,class B>
- BOOST_QVM_INLINE_OPERATIONS
- typename enable_if_c<
- vec_traits<A>::dim==2 && vec_traits<B>::dim==2,
- A &>::type
- operator-=( A & a, B const & b )
- {
- vec_traits<A>::template write_element<0>(a)-=vec_traits<B>::template read_element<0>(b);
- vec_traits<A>::template write_element<1>(a)-=vec_traits<B>::template read_element<1>(b);
- return a;
- }
- namespace
- sfinae
- {
- using ::boost::qvm::operator-=;
- }
- namespace
- qvm_detail
- {
- template <int D>
- struct minus_eq_vv_defined;
- template <>
- struct
- minus_eq_vv_defined<2>
- {
- static bool const value=true;
- };
- }
- template <class A,class B>
- BOOST_QVM_INLINE_OPERATIONS
- typename lazy_enable_if_c<
- vec_traits<A>::dim==2 && is_scalar<B>::value,
- deduce_vec2<A,B,vec_traits<A>::dim> >::type
- operator*( A const & a, B b )
- {
- typedef typename deduce_vec2<A,B,vec_traits<A>::dim>::type R;
- R r;
- vec_traits<R>::template write_element<0>(r)=vec_traits<A>::template read_element<0>(a)*b;
- vec_traits<R>::template write_element<1>(r)=vec_traits<A>::template read_element<1>(a)*b;
- return r;
- }
- namespace
- sfinae
- {
- using ::boost::qvm::operator*;
- }
- namespace
- qvm_detail
- {
- template <int D>
- struct mul_vs_defined;
- template <>
- struct
- mul_vs_defined<2>
- {
- static bool const value=true;
- };
- }
- template <class A,class B>
- BOOST_QVM_INLINE_OPERATIONS
- typename lazy_enable_if_c<
- is_scalar<A>::value && vec_traits<B>::dim==2,
- deduce_vec2<A,B,vec_traits<B>::dim> >::type
- operator*( A a, B const & b )
- {
- typedef typename deduce_vec2<A,B,vec_traits<B>::dim>::type R;
- R r;
- vec_traits<R>::template write_element<0>(r)=a*vec_traits<B>::template read_element<0>(b);
- vec_traits<R>::template write_element<1>(r)=a*vec_traits<B>::template read_element<1>(b);
- return r;
- }
- namespace
- sfinae
- {
- using ::boost::qvm::operator*;
- }
- namespace
- qvm_detail
- {
- template <int D>
- struct mul_sv_defined;
- template <>
- struct
- mul_sv_defined<2>
- {
- static bool const value=true;
- };
- }
- template <class A,class B>
- BOOST_QVM_INLINE_OPERATIONS
- typename enable_if_c<
- vec_traits<A>::dim==2 && is_scalar<B>::value,
- A &>::type
- operator*=( A & a, B b )
- {
- vec_traits<A>::template write_element<0>(a)*=b;
- vec_traits<A>::template write_element<1>(a)*=b;
- return a;
- }
- namespace
- sfinae
- {
- using ::boost::qvm::operator*=;
- }
- namespace
- qvm_detail
- {
- template <int D>
- struct mul_eq_vs_defined;
- template <>
- struct
- mul_eq_vs_defined<2>
- {
- static bool const value=true;
- };
- }
- template <class A,class B>
- BOOST_QVM_INLINE_OPERATIONS
- typename lazy_enable_if_c<
- vec_traits<A>::dim==2 && is_scalar<B>::value,
- deduce_vec2<A,B,vec_traits<A>::dim> >::type
- operator/( A const & a, B b )
- {
- typedef typename deduce_vec2<A,B,vec_traits<A>::dim>::type R;
- R r;
- vec_traits<R>::template write_element<0>(r)=vec_traits<A>::template read_element<0>(a)/b;
- vec_traits<R>::template write_element<1>(r)=vec_traits<A>::template read_element<1>(a)/b;
- return r;
- }
- namespace
- sfinae
- {
- using ::boost::qvm::operator/;
- }
- namespace
- qvm_detail
- {
- template <int D>
- struct div_vs_defined;
- template <>
- struct
- div_vs_defined<2>
- {
- static bool const value=true;
- };
- }
- template <class A,class B>
- BOOST_QVM_INLINE_OPERATIONS
- typename enable_if_c<
- vec_traits<A>::dim==2 && is_scalar<B>::value,
- A &>::type
- operator/=( A & a, B b )
- {
- vec_traits<A>::template write_element<0>(a)/=b;
- vec_traits<A>::template write_element<1>(a)/=b;
- return a;
- }
- namespace
- sfinae
- {
- using ::boost::qvm::operator/=;
- }
- namespace
- qvm_detail
- {
- template <int D>
- struct div_eq_vs_defined;
- template <>
- struct
- div_eq_vs_defined<2>
- {
- static bool const value=true;
- };
- }
- template <class R,class A>
- BOOST_QVM_INLINE_OPERATIONS
- typename enable_if_c<
- is_vec<A>::value &&
- vec_traits<R>::dim==2 && vec_traits<A>::dim==2,
- R>::type
- convert_to( A const & a )
- {
- R r;
- vec_traits<R>::template write_element<0>(r)=vec_traits<A>::template read_element<0>(a);
- vec_traits<R>::template write_element<1>(r)=vec_traits<A>::template read_element<1>(a);
- return r;
- }
- namespace
- sfinae
- {
- using ::boost::qvm::convert_to;
- }
- namespace
- qvm_detail
- {
- template <int D>
- struct convert_to_v_defined;
- template <>
- struct
- convert_to_v_defined<2>
- {
- static bool const value=true;
- };
- }
- template <class A,class B>
- BOOST_QVM_INLINE_OPERATIONS
- typename enable_if_c<
- vec_traits<A>::dim==2 && vec_traits<B>::dim==2,
- bool>::type
- operator==( A const & a, B const & b )
- {
- return
- vec_traits<A>::template read_element<0>(a)==vec_traits<B>::template read_element<0>(b) &&
- vec_traits<A>::template read_element<1>(a)==vec_traits<B>::template read_element<1>(b);
- }
- namespace
- sfinae
- {
- using ::boost::qvm::operator==;
- }
- namespace
- qvm_detail
- {
- template <int D>
- struct eq_vv_defined;
- template <>
- struct
- eq_vv_defined<2>
- {
- static bool const value=true;
- };
- }
- template <class A,class B>
- BOOST_QVM_INLINE_OPERATIONS
- typename enable_if_c<
- vec_traits<A>::dim==2 && vec_traits<B>::dim==2,
- bool>::type
- operator!=( A const & a, B const & b )
- {
- return
- !(vec_traits<A>::template read_element<0>(a)==vec_traits<B>::template read_element<0>(b)) ||
- !(vec_traits<A>::template read_element<1>(a)==vec_traits<B>::template read_element<1>(b));
- }
- namespace
- sfinae
- {
- using ::boost::qvm::operator!=;
- }
- namespace
- qvm_detail
- {
- template <int D>
- struct neq_vv_defined;
- template <>
- struct
- neq_vv_defined<2>
- {
- static bool const value=true;
- };
- }
- template <class A>
- BOOST_QVM_INLINE_OPERATIONS
- typename lazy_enable_if_c<
- vec_traits<A>::dim==2,
- deduce_vec<A> >::type
- operator-( A const & a )
- {
- typedef typename deduce_vec<A>::type R;
- R r;
- vec_traits<R>::template write_element<0>(r)=-vec_traits<A>::template read_element<0>(a);
- vec_traits<R>::template write_element<1>(r)=-vec_traits<A>::template read_element<1>(a);
- return r;
- }
- namespace
- sfinae
- {
- using ::boost::qvm::operator-;
- }
- namespace
- qvm_detail
- {
- template <int D>
- struct minus_v_defined;
- template <>
- struct
- minus_v_defined<2>
- {
- static bool const value=true;
- };
- }
- template <class A>
- BOOST_QVM_INLINE_OPERATIONS
- typename enable_if_c<
- is_vec<A>::value && vec_traits<A>::dim==2,
- typename vec_traits<A>::scalar_type>::type
- mag( A const & a )
- {
- typedef typename vec_traits<A>::scalar_type T;
- T const a0=vec_traits<A>::template read_element<0>(a);
- T const a1=vec_traits<A>::template read_element<1>(a);
- T const m2=a0*a0+a1*a1;
- T const mag=sqrt<T>(m2);
- return mag;
- }
- namespace
- sfinae
- {
- using ::boost::qvm::mag;
- }
- namespace
- qvm_detail
- {
- template <int D>
- struct mag_v_defined;
- template <>
- struct
- mag_v_defined<2>
- {
- static bool const value=true;
- };
- }
- template <class A>
- BOOST_QVM_INLINE_OPERATIONS
- typename enable_if_c<
- is_vec<A>::value && vec_traits<A>::dim==2,
- typename vec_traits<A>::scalar_type>::type
- mag_sqr( A const & a )
- {
- typedef typename vec_traits<A>::scalar_type T;
- T const a0=vec_traits<A>::template read_element<0>(a);
- T const a1=vec_traits<A>::template read_element<1>(a);
- T const m2=a0*a0+a1*a1;
- return m2;
- }
- namespace
- sfinae
- {
- using ::boost::qvm::mag_sqr;
- }
- namespace
- qvm_detail
- {
- template <int D>
- struct mag_sqr_v_defined;
- template <>
- struct
- mag_sqr_v_defined<2>
- {
- static bool const value=true;
- };
- }
- template <class A>
- BOOST_QVM_INLINE_OPERATIONS
- typename lazy_enable_if_c<
- vec_traits<A>::dim==2,
- deduce_vec<A> >::type
- normalized( A const & a )
- {
- typedef typename vec_traits<A>::scalar_type T;
- T const a0=vec_traits<A>::template read_element<0>(a);
- T const a1=vec_traits<A>::template read_element<1>(a);
- T const m2=a0*a0+a1*a1;
- if( m2==scalar_traits<typename vec_traits<A>::scalar_type>::value(0) )
- BOOST_QVM_THROW_EXCEPTION(zero_magnitude_error());
- T const rm=scalar_traits<T>::value(1)/sqrt<T>(m2);
- typedef typename deduce_vec<A>::type R;
- R r;
- vec_traits<R>::template write_element<0>(r)=a0*rm;
- vec_traits<R>::template write_element<1>(r)=a1*rm;
- return r;
- }
- namespace
- sfinae
- {
- using ::boost::qvm::normalized;
- }
- template <class A>
- BOOST_QVM_INLINE_OPERATIONS
- typename enable_if_c<
- vec_traits<A>::dim==2,
- void>::type
- normalize( A & a )
- {
- typedef typename vec_traits<A>::scalar_type T;
- T const a0=vec_traits<A>::template read_element<0>(a);
- T const a1=vec_traits<A>::template read_element<1>(a);
- T const m2=a0*a0+a1*a1;
- if( m2==scalar_traits<typename vec_traits<A>::scalar_type>::value(0) )
- BOOST_QVM_THROW_EXCEPTION(zero_magnitude_error());
- T const rm=scalar_traits<T>::value(1)/sqrt<T>(m2);
- vec_traits<A>::template write_element<0>(a)*=rm;
- vec_traits<A>::template write_element<1>(a)*=rm;
- }
- namespace
- sfinae
- {
- using ::boost::qvm::normalize;
- }
- namespace
- qvm_detail
- {
- template <int D>
- struct normalize_v_defined;
- template <>
- struct
- normalize_v_defined<2>
- {
- static bool const value=true;
- };
- }
- template <class A,class B>
- BOOST_QVM_INLINE_OPERATIONS
- typename lazy_enable_if_c<
- vec_traits<A>::dim==2 && vec_traits<B>::dim==2,
- deduce_scalar<typename vec_traits<A>::scalar_type,typename vec_traits<B>::scalar_type> >::type
- dot( A const & a, B const & b )
- {
- typedef typename vec_traits<A>::scalar_type Ta;
- typedef typename vec_traits<B>::scalar_type Tb;
- typedef typename deduce_scalar<Ta,Tb>::type Tr;
- Ta const a0=vec_traits<A>::template read_element<0>(a);
- Ta const a1=vec_traits<A>::template read_element<1>(a);
- Tb const b0=vec_traits<B>::template read_element<0>(b);
- Tb const b1=vec_traits<B>::template read_element<1>(b);
- Tr const dot=a0*b0+a1*b1;
- return dot;
- }
- namespace
- sfinae
- {
- using ::boost::qvm::dot;
- }
- namespace
- qvm_detail
- {
- template <int D>
- struct dot_vv_defined;
- template <>
- struct
- dot_vv_defined<2>
- {
- static bool const value=true;
- };
- }
- } }
- #endif
|