⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 quaternion.hpp

📁 CGAL is a collaborative effort of several sites in Europe and Israel. The goal is to make the most i
💻 HPP
📖 第 1 页 / 共 5 页
字号:
            // (this is taken care of by the compiler itself)                        // converting copy constructors                        explicit                    quaternion(quaternion<float> const & a_recopier)            {                *this = detail::quaternion_type_converter<long double, float>(a_recopier);            }                        explicit                    quaternion(quaternion<double> const & a_recopier)            {                *this = detail::quaternion_type_converter<long double, double>(a_recopier);            }                        // destructor            // (this is taken care of by the compiler itself)                        // accessors            //            // Note:    Like complex number, quaternions do have a meaningful notion of "real part",            //            but unlike them there is no meaningful notion of "imaginary part".            //            Instead there is an "unreal part" which itself is a quaternion, and usually            //            nothing simpler (as opposed to the complex number case).            //            However, for practicallity, there are accessors for the other components            //            (these are necessary for the templated copy constructor, for instance).                        BOOST_QUATERNION_ACCESSOR_GENERATOR(long double)                        // assignment operators                        BOOST_QUATERNION_MEMBER_ASSIGNMENT_GENERATOR(long double)                        // other assignment-related operators            //            // NOTE:    Quaternion multiplication is *NOT* commutative;            //            symbolically, "q *= rhs;" means "q = q * rhs;"            //            and "q /= rhs;" means "q = q * inverse_of(rhs);"                        BOOST_QUATERNION_MEMBER_ALGEBRAIC_GENERATOR(long double)                                protected:                        BOOST_QUATERNION_MEMBER_DATA_GENERATOR(long double)                                private:                    };                #undef    BOOST_QUATERNION_MEMBER_ALGEBRAIC_GENERATOR#undef    BOOST_QUATERNION_MEMBER_ADD_GENERATOR#undef    BOOST_QUATERNION_MEMBER_SUB_GENERATOR#undef    BOOST_QUATERNION_MEMBER_MUL_GENERATOR#undef    BOOST_QUATERNION_MEMBER_DIV_GENERATOR#undef    BOOST_QUATERNION_MEMBER_ADD_GENERATOR_1#undef    BOOST_QUATERNION_MEMBER_ADD_GENERATOR_2#undef    BOOST_QUATERNION_MEMBER_ADD_GENERATOR_3#undef    BOOST_QUATERNION_MEMBER_SUB_GENERATOR_1#undef    BOOST_QUATERNION_MEMBER_SUB_GENERATOR_2#undef    BOOST_QUATERNION_MEMBER_SUB_GENERATOR_3#undef    BOOST_QUATERNION_MEMBER_MUL_GENERATOR_1#undef    BOOST_QUATERNION_MEMBER_MUL_GENERATOR_2#undef    BOOST_QUATERNION_MEMBER_MUL_GENERATOR_3#undef    BOOST_QUATERNION_MEMBER_DIV_GENERATOR_1#undef    BOOST_QUATERNION_MEMBER_DIV_GENERATOR_2#undef    BOOST_QUATERNION_MEMBER_DIV_GENERATOR_3        #undef    BOOST_QUATERNION_CONSTRUCTOR_GENERATOR                #undef    BOOST_QUATERNION_MEMBER_ASSIGNMENT_GENERATOR        #undef    BOOST_QUATERNION_MEMBER_DATA_GENERATOR        #undef    BOOST_QUATERNION_ACCESSOR_GENERATOR                        // operators        #define    BOOST_QUATERNION_OPERATOR_GENERATOR_BODY(op)      \        {                                                    \            quaternion<T>    res(lhs);                       \            res op##= rhs;                                   \            return(res);                                     \        }        #define    BOOST_QUATERNION_OPERATOR_GENERATOR_1_L(op)                                                  \        template<typename T>                                                                            \        inline quaternion<T>    operator op (T const & lhs, quaternion<T> const & rhs)                  \        BOOST_QUATERNION_OPERATOR_GENERATOR_BODY(op)        #define    BOOST_QUATERNION_OPERATOR_GENERATOR_1_R(op)                                                  \        template<typename T>                                                                            \        inline quaternion<T>    operator op (quaternion<T> const & lhs, T const & rhs)                  \        BOOST_QUATERNION_OPERATOR_GENERATOR_BODY(op)        #define    BOOST_QUATERNION_OPERATOR_GENERATOR_2_L(op)                                                  \        template<typename T>                                                                            \        inline quaternion<T>    operator op (::std::complex<T> const & lhs, quaternion<T> const & rhs)  \        BOOST_QUATERNION_OPERATOR_GENERATOR_BODY(op)        #define    BOOST_QUATERNION_OPERATOR_GENERATOR_2_R(op)                                                  \        template<typename T>                                                                            \        inline quaternion<T>    operator op (quaternion<T> const & lhs, ::std::complex<T> const & rhs)  \        BOOST_QUATERNION_OPERATOR_GENERATOR_BODY(op)        #define    BOOST_QUATERNION_OPERATOR_GENERATOR_3(op)                                                    \        template<typename T>                                                                            \        inline quaternion<T>    operator op (quaternion<T> const & lhs, quaternion<T> const & rhs)      \        BOOST_QUATERNION_OPERATOR_GENERATOR_BODY(op)        #define    BOOST_QUATERNION_OPERATOR_GENERATOR(op)     \        BOOST_QUATERNION_OPERATOR_GENERATOR_1_L(op)    \        BOOST_QUATERNION_OPERATOR_GENERATOR_1_R(op)    \        BOOST_QUATERNION_OPERATOR_GENERATOR_2_L(op)    \        BOOST_QUATERNION_OPERATOR_GENERATOR_2_R(op)    \        BOOST_QUATERNION_OPERATOR_GENERATOR_3(op)                        BOOST_QUATERNION_OPERATOR_GENERATOR(+)        BOOST_QUATERNION_OPERATOR_GENERATOR(-)        BOOST_QUATERNION_OPERATOR_GENERATOR(*)        BOOST_QUATERNION_OPERATOR_GENERATOR(/)#undef    BOOST_QUATERNION_OPERATOR_GENERATOR        #undef    BOOST_QUATERNION_OPERATOR_GENERATOR_1_L#undef    BOOST_QUATERNION_OPERATOR_GENERATOR_1_R#undef    BOOST_QUATERNION_OPERATOR_GENERATOR_2_L#undef    BOOST_QUATERNION_OPERATOR_GENERATOR_2_R#undef    BOOST_QUATERNION_OPERATOR_GENERATOR_3#undef    BOOST_QUATERNION_OPERATOR_GENERATOR_BODY                        template<typename T>        inline quaternion<T>                    operator + (quaternion<T> const & q)        {            return(q);        }                        template<typename T>        inline quaternion<T>                    operator - (quaternion<T> const & q)        {            return(quaternion<T>(-q.R_component_1(),-q.R_component_2(),-q.R_component_3(),-q.R_component_4()));        }                        template<typename T>        inline bool                                operator == (T const & lhs, quaternion<T> const & rhs)        {            return    (                        (rhs.R_component_1() == lhs)&&                        (rhs.R_component_2() == static_cast<T>(0))&&                        (rhs.R_component_3() == static_cast<T>(0))&&                        (rhs.R_component_4() == static_cast<T>(0))                    );        }                        template<typename T>        inline bool                                operator == (quaternion<T> const & lhs, T const & rhs)        {            return    (                        (lhs.R_component_1() == rhs)&&                        (lhs.R_component_2() == static_cast<T>(0))&&                        (lhs.R_component_3() == static_cast<T>(0))&&                        (lhs.R_component_4() == static_cast<T>(0))                    );        }                        template<typename T>        inline bool                                operator == (::std::complex<T> const & lhs, quaternion<T> const & rhs)        {            return    (                        (rhs.R_component_1() == lhs.real())&&                        (rhs.R_component_2() == lhs.imag())&&                        (rhs.R_component_3() == static_cast<T>(0))&&                        (rhs.R_component_4() == static_cast<T>(0))                    );        }                        template<typename T>        inline bool                                operator == (quaternion<T> const & lhs, ::std::complex<T> const & rhs)        {            return    (                        (lhs.R_component_1() == rhs.real())&&                        (lhs.R_component_2() == rhs.imag())&&                        (lhs.R_component_3() == static_cast<T>(0))&&                        (lhs.R_component_4() == static_cast<T>(0))                    );        }                        template<typename T>        inline bool                                operator == (quaternion<T> const & lhs, quaternion<T> const & rhs)        {            return    (                        (rhs.R_component_1() == lhs.R_component_1())&&                        (rhs.R_component_2() == lhs.R_component_2())&&                        (rhs.R_component_3() == lhs.R_component_3())&&                        (rhs.R_component_4() == lhs.R_component_4())                    );        }                #define    BOOST_QUATERNION_NOT_EQUAL_GENERATOR  \        {                                        \            return(!(lhs == rhs));               \        }                template<typename T>        inline bool                                operator != (T const & lhs, quaternion<T> const & rhs)        BOOST_QUATERNION_NOT_EQUAL_GENERATOR                template<typename T>        inline bool                                operator != (quaternion<T> const & lhs, T const & rhs)        BOOST_QUATERNION_NOT_EQUAL_GENERATOR                template<typename T>        inline bool                                operator != (::std::complex<T> const & lhs, quaternion<T> const & rhs)        BOOST_QUATERNION_NOT_EQUAL_GENERATOR                template<typename T>        inline bool                                operator != (quaternion<T> const & lhs, ::std::complex<T> const & rhs)        BOOST_QUATERNION_NOT_EQUAL_GENERATOR                template<typename T>        inline bool                                operator != (quaternion<T> const & lhs, quaternion<T> const & rhs)        BOOST_QUATERNION_NOT_EQUAL_GENERATOR        #undef    BOOST_QUATERNION_NOT_EQUAL_GENERATOR                        // Note:    we allow the following formats, whith a, b, c, and d reals        //            a      

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -