X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2FMoof%2Fcml%2Fquaternion%2Fquatop_macros.h;fp=src%2FMoof%2Fcml%2Fquaternion%2Fquatop_macros.h;h=112e34855f818c0037d005a7bea3c5c63776c67b;hp=0000000000000000000000000000000000000000;hb=c2321281bf12a7efaedde930422c7ddbc92080d4;hpb=87bc17e55b0c1dc73ecc66df856d3f08fd7a7724 diff --git a/src/Moof/cml/quaternion/quatop_macros.h b/src/Moof/cml/quaternion/quatop_macros.h new file mode 100644 index 0000000..112e348 --- /dev/null +++ b/src/Moof/cml/quaternion/quatop_macros.h @@ -0,0 +1,232 @@ +/* -*- 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