stator
A math, geometry, and utility library
indicator.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2017 Marcus N Campbell Bannerman <[email protected]>
3 
4  This file is part of stator.
5 
6  stator is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  stator is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with stator. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #pragma once
21 
22 // stator
23 #include "stator/config.hpp"
28 
29 namespace stator {
30  namespace geometry {
31  using namespace stator::symbolic;
32 
34  template<class Scalar, size_t D, class DeltaRijFunc>
35  auto indicator(const Ball<Scalar, D>& bi, const Point<Scalar, D>& bj, const DeltaRijFunc& deltarij)
36  -> STATOR_AUTORETURN_BYVALUE(pow<2>(try_simplify(deltarij + bi.center() - bj.center())) - pow<2>(bi.radius()));
37 
39  template<class Scalar, size_t D, class DeltaRijFunc>
40  auto indicator(const Point<Scalar, D>& bi, const Ball<Scalar, D>& bj, const DeltaRijFunc& deltarij)
41  -> STATOR_AUTORETURN_BYVALUE(indicator(bj, bi, -deltarij));
42 
44  template<class Scalar, size_t D, class DeltaRijFunc>
45  auto indicator(const Ball<Scalar, D>& bi, const Ball<Scalar, D>& bj, const DeltaRijFunc& deltarij)
46  -> STATOR_AUTORETURN_BYVALUE(pow<2>(try_simplify(deltarij + bi.center() - bj.center())) - pow<2>(bi.radius() + bj.radius()));
47 
49  template<class Scalar, size_t D, class DeltaRijFunc>
50  auto indicator(const Ball<Scalar, D>& bi, const HalfSpace<Scalar, D>& bj, const DeltaRijFunc& deltarij)
51  -> STATOR_AUTORETURN_BYVALUE(try_simplify(dot(bj.normal(), deltarij + bi.center() - bj.center()) - bi.radius()));
52 
54  template<class Scalar, size_t D, class DeltaRijFunc>
55  auto indicator(const HalfSpace<Scalar, D>& bi, const Ball<Scalar, D>& bj, const DeltaRijFunc& deltarij)
56  -> STATOR_AUTORETURN_BYVALUE(indicator(bj, bi, -deltarij));
57 
61  template<typename Obj1, typename Obj2>
62  auto intersects(const Obj1& b1, const Obj2& b2)
63  -> STATOR_AUTORETURN(indicator(b1, b2, Null()) < 0)
64 
65  } // namespace geometry
66 } // namespace stator
#define STATOR_AUTORETURN_BYVALUE(EXPR)
A convenience Macro for defining auto by-value return type functions.
Definition: config.hpp:107
auto try_simplify(const T &a) -> decltype(detail::try_simplify_imp< Config >(a, detail::select_overload
A method to apply simplification only if it is available.
Definition: simplify.hpp:84
C< 0 > Null
A symbolic representation of zero.
Definition: constants.hpp:51
Fundamental typedef&#39;s and macros for stator.
Main header for the stator::symbolic library.
#define STATOR_AUTORETURN(EXPR)
A convenience Macro for defining auto return type functions.
Definition: config.hpp:51
auto indicator(const Ball< Scalar, D > &bi, const Point< Scalar, D > &bj, const DeltaRijFunc &deltarij) -> STATOR_AUTORETURN_BYVALUE(pow< 2 >(try_simplify(deltarij+bi.center() - bj.center())) - pow< 2 >(bi.radius()))
Ball-Point indicator function.
The stator library namespace.
Definition: frontpage.dox:243
bool intersects(const Object1 &, const Object2 &)
Determine if two objects are intersecting.