/* -*- C++ -*- ------------------------------------------------------------ Copyright (c) 2007 Jesse Anders and Demian Nave http://cmldev.net/ The Configurable Math Library (CML) is distributed under the terms of the Boost Software License, v1.0 (see cml/LICENSE for details). *-----------------------------------------------------------------------*/ /** @file * @brief * * Create unary and binary operators with macros. * * These macros work just like those in cml/quaternion/vecop_macros.h. */ #ifndef quatop_macros_h #define quatop_macros_h /** Declare a unary operator taking a quaternion operand. */ #define CML_QUAT_UNIOP(_op_, _OpT_) \ template \ inline et::QuaternionXpr< \ et::UnaryQuaternionOp< quaternion, _OpT_ > \ > \ \ _op_ (const quaternion& arg) \ { \ typedef et::UnaryQuaternionOp< \ quaternion, _OpT_ \ > ExprT; \ return et::QuaternionXpr(ExprT(arg)); \ } /** Declare a unary operator taking a et::QuaternionXpr operand. */ #define CML_QUATXPR_UNIOP(_op_, _OpT_) \ template \ inline et::QuaternionXpr< \ et::UnaryQuaternionOp< XprT, _OpT_ > \ > \ \ _op_ (QUATXPR_ARG_TYPE arg) \ { \ typedef et::UnaryQuaternionOp< \ XprT, _OpT_ \ > ExprT; \ return et::QuaternionXpr(ExprT(arg.expression())); \ } /** Declare an operator taking two quaternion operands. */ #define CML_QUAT_QUAT_BINOP(_op_, _OpT_) \ template \ inline et::QuaternionXpr< \ et::BinaryQuaternionOp< \ quaternion, quaternion, \ _OpT_ \ > \ > \ \ _op_ ( \ const quaternion& left, \ const quaternion& right) \ { \ typedef et::BinaryQuaternionOp< \ quaternion, quaternion, \ _OpT_ \ > ExprT; \ return et::QuaternionXpr(ExprT(left,right)); \ } /** Declare an operator taking a quaternion and a et::QuaternionXpr. */ #define CML_QUAT_QUATXPR_BINOP(_op_, _OpT_) \ template \ inline et::QuaternionXpr< \ et::BinaryQuaternionOp< \ quaternion, XprT, \ _OpT_ \ > \ > \ \ _op_ ( \ const quaternion& left, \ QUATXPR_ARG_TYPE right) \ { \ typedef et::BinaryQuaternionOp< \ quaternion, XprT, \ _OpT_ \ > ExprT; \ return et::QuaternionXpr(ExprT(left,right.expression())); \ } /** Declare an operator taking an et::QuaternionXpr and a quaternion. */ #define CML_QUATXPR_QUAT_BINOP(_op_, _OpT_) \ template \ inline et::QuaternionXpr< \ et::BinaryQuaternionOp< \ XprT, quaternion, \ _OpT_ \ > \ > \ \ _op_ ( \ QUATXPR_ARG_TYPE left, \ const quaternion& right) \ { \ typedef et::BinaryQuaternionOp< \ XprT, quaternion, \ _OpT_ \ > ExprT; \ return et::QuaternionXpr(ExprT(left.expression(),right)); \ } /** Declare an operator taking two et::QuaternionXpr operands. */ #define CML_QUATXPR_QUATXPR_BINOP(_op_, _OpT_) \ template \ inline et::QuaternionXpr< \ et::BinaryQuaternionOp< \ XprT1, XprT2, \ _OpT_ < \ typename XprT1::value_type, \ typename XprT2::value_type \ > \ > \ > \ \ _op_ ( \ QUATXPR_ARG_TYPE_N(1) left, \ QUATXPR_ARG_TYPE_N(2) right) \ { \ typedef et::BinaryQuaternionOp< \ XprT1, XprT2, \ _OpT_ < \ typename XprT1::value_type, \ typename XprT2::value_type> \ > ExprT; \ return et::QuaternionXpr( \ ExprT(left.expression(),right.expression())); \ } /** Declare an operator taking a quaternion and a scalar. */ #define CML_QUAT_SCALAR_BINOP(_op_, _OpT_) \ template \ inline et::QuaternionXpr< \ et::BinaryQuaternionOp< \ quaternion, ScalarT, \ _OpT_ \ > \ > \ \ _op_ ( \ const quaternion& left, \ SCALAR_ARG_TYPE right) \ { \ typedef et::BinaryQuaternionOp< \ quaternion, ScalarT, _OpT_ \ > ExprT; \ return et::QuaternionXpr(ExprT(left,right)); \ } /** Declare an operator taking a scalar and a quaternion. */ #define CML_SCALAR_QUAT_BINOP(_op_, _OpT_) \ template \ inline et::QuaternionXpr< \ et::BinaryQuaternionOp< \ ScalarT, quaternion, _OpT_ \ > \ > \ \ _op_ ( \ SCALAR_ARG_TYPE left, \ const quaternion& right) \ { \ typedef et::BinaryQuaternionOp< \ ScalarT, quaternion, _OpT_ \ > ExprT; \ return et::QuaternionXpr(ExprT(left,right)); \ } /** Declare an operator taking a et::QuaternionXpr and a scalar. */ #define CML_QUATXPR_SCALAR_BINOP(_op_, _OpT_) \ template \ inline et::QuaternionXpr< \ et::BinaryQuaternionOp< \ XprT, ScalarT, _OpT_ \ > \ > \ \ _op_ ( \ QUATXPR_ARG_TYPE left, \ SCALAR_ARG_TYPE right) \ { \ typedef et::BinaryQuaternionOp< \ XprT, ScalarT, _OpT_ \ > ExprT; \ return et::QuaternionXpr(ExprT(left.expression(),right)); \ } /** Declare an operator taking a scalar and a et::QuaternionXpr. */ #define CML_SCALAR_QUATXPR_BINOP(_op_, _OpT_) \ template \ inline et::QuaternionXpr< \ et::BinaryQuaternionOp< \ ScalarT, XprT, _OpT_ \ > \ > \ \ _op_ ( \ SCALAR_ARG_TYPE left, \ QUATXPR_ARG_TYPE right) \ { \ typedef et::BinaryQuaternionOp< \ ScalarT, XprT, \ _OpT_ \ > ExprT; \ return et::QuaternionXpr(ExprT(left,right.expression())); \ } #endif // ------------------------------------------------------------------------- // vim:ft=cpp