X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2Fcml%2Fquaternion%2Fquaternion_comparison.h;fp=src%2Fcml%2Fquaternion%2Fquaternion_comparison.h;h=0000000000000000000000000000000000000000;hp=c1e6d0c5bfefca3b1cfdf03ec3e898839a64a822;hb=c2321281bf12a7efaedde930422c7ddbc92080d4;hpb=87bc17e55b0c1dc73ecc66df856d3f08fd7a7724 diff --git a/src/cml/quaternion/quaternion_comparison.h b/src/cml/quaternion/quaternion_comparison.h deleted file mode 100644 index c1e6d0c..0000000 --- a/src/cml/quaternion/quaternion_comparison.h +++ /dev/null @@ -1,216 +0,0 @@ -/* -*- 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 - */ - -#ifndef quaternion_comparison_h -#define quaternion_comparison_h - -#include -#include - -/* This is used below to create a more meaningful compile-time error when - * quaternion_comparison is not provided with quaternion or QuaternionExpr arguments: - */ -struct quaternion_comparison_expects_quaternion_args_error; - -#define CML_QUAT_QUAT_ORDER(_order_, _op_, _OpT_) \ -template< \ - typename E1, class AT1, typename E2, class AT2, class O, class C > \ -inline bool \ -_op_ ( \ - const quaternion& left, \ - const quaternion& right) \ -{ \ - return detail::quaternion_##_order_ (left, right, _OpT_ ()); \ -} - -#define CML_QUAT_QUATXPR_ORDER(_order_, _op_, _OpT_) \ -template \ -inline bool \ -_op_ ( \ - const quaternion& left, \ - QUATXPR_ARG_TYPE right) \ -{ \ - return detail::quaternion_##_order_ (left, right, \ - _OpT_ ()); \ -} - -#define CML_QUATXPR_QUAT_ORDER(_order_, _op_, _OpT_) \ -template \ -inline bool \ -_op_ ( \ - QUATXPR_ARG_TYPE left, \ - const quaternion& right) \ -{ \ - return detail::quaternion_##_order_ (left, right, \ - _OpT_ ()); \ -} - -#define CML_QUATXPR_QUATXPR_ORDER(_order_, _op_, _OpT_) \ -template \ -inline bool \ -_op_ ( \ - QUATXPR_ARG_TYPE_N(1) left, \ - QUATXPR_ARG_TYPE_N(2) right) \ -{ \ - return detail::quaternion_##_order_ (left, right, \ - _OpT_ < \ - typename XprT1::value_type, \ - typename XprT2::value_type>()); \ -} - - -namespace cml { -namespace detail { - -/** Quaternion strict weak ordering relationship. - * - * OpT must implement a strict weak order on the quaternion element type. - * operator< and operator> on integer and floating-point types are - * examples. - */ -template -inline bool -quaternion_weak_order(const LeftT& left, const RightT& right, OpT) -{ - /* Shorthand: */ - typedef et::ExprTraits left_traits; - typedef et::ExprTraits right_traits; - - /* quaternion_comparison() requires quaternion expressions: */ - CML_STATIC_REQUIRE_M( - (et::QuaternionExpressions::is_true), - quaternion_comparison_expects_quaternion_args_error); - /* Note: parens are required here so that the preprocessor ignores the - * commas: - */ - - typedef typename et::QuaternionPromote< - typename left_traits::result_type, - typename right_traits::result_type - >::type result_type; - - for(ssize_t i = 0; i < result_type::array_size; ++ i) { - - if(OpT().apply( - left_traits().get(left,i), - right_traits().get(right,i) - )) - { - /* If weak order (a < b) is satisfied, return true: */ - return true; - } else if(OpT().apply( - right_traits().get(right,i), - left_traits().get(left,i) - )) - { - /* If !(b < a), then return false: */ - return false; - } else { - - /* Have !(a < b) && !(b < a) <=> (a >= b && b >= a) <=> (a == b). - * so need to test next element: - */ - continue; - } - } - /* XXX Can this be unrolled in any reasonable way? */ - - /* If we get here, then left == right: */ - return false; -} - -/** Quaternion total order relationship. - * - * OpT must implement a total order on the quaternion element type. operator<= - * and operator>= on integer and floating-point types are examples. - */ -template -inline bool -quaternion_total_order(const LeftT& left, const RightT& right, OpT) -{ - /* Shorthand: */ - typedef et::ExprTraits left_traits; - typedef et::ExprTraits right_traits; - - /* quaternion_comparison() requires quaternion expressions: */ - CML_STATIC_REQUIRE_M( - (et::QuaternionExpressions::is_true), - quaternion_comparison_expects_quaternion_args_error); - /* Note: parens are required here so that the preprocessor ignores the - * commas: - */ - - typedef typename et::QuaternionPromote< - typename left_traits::result_type, - typename right_traits::result_type - >::type result_type; - - for(ssize_t i = 0; i < result_type::array_size; ++ i) { - - /* Test total order: */ - if(OpT().apply( - left_traits().get(left,i), - right_traits().get(right,i) - )) - { - /* Automatically true if weak order (a <= b) && !(b <= a) <=> - * (a <= b) && (b > a) <=> (a < b) is satisfied: - */ - if(!OpT().apply( - right_traits().get(right,i), - left_traits().get(left,i) - )) - return true; - - /* Otherwise, have equality (a <= b) && (b <= a), so continue - * to next element: - */ - else - continue; - - } else { - - /* Total order isn't satisfied (a > b), so return false: */ - return false; - } - } - /* XXX Can this be unrolled in any reasonable way? */ - - /* Total (==) or weak (<) order was satisfied, so return true: */ - return true; -} - -} - -/* XXX There is a better way to handle these with operator traits... */ - -CML_QUAT_QUAT_ORDER( total_order, operator==, et::OpEqual) -CML_QUATXPR_QUAT_ORDER( total_order, operator==, et::OpEqual) -CML_QUAT_QUATXPR_ORDER( total_order, operator==, et::OpEqual) -CML_QUATXPR_QUATXPR_ORDER( total_order, operator==, et::OpEqual) - -CML_QUAT_QUAT_ORDER( weak_order, operator!=, et::OpNotEqual) -CML_QUATXPR_QUAT_ORDER( weak_order, operator!=, et::OpNotEqual) -CML_QUAT_QUATXPR_ORDER( weak_order, operator!=, et::OpNotEqual) -CML_QUATXPR_QUATXPR_ORDER( weak_order, operator!=, et::OpNotEqual) - -CML_QUAT_QUAT_ORDER( weak_order, operator<, et::OpLess) -CML_QUATXPR_QUAT_ORDER( weak_order, operator<, et::OpLess) -CML_QUAT_QUATXPR_ORDER( weak_order, operator<, et::OpLess) -CML_QUATXPR_QUATXPR_ORDER( weak_order, operator<, et::OpLess) - -} // namespace cml - -#endif - -// ------------------------------------------------------------------------- -// vim:ft=cpp