-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change-Id: I672378174643d5bbf580375b61bc9552ed0d62cf
- Loading branch information
Showing
6 changed files
with
124 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#pragma once | ||
|
||
#include "geometry/expression_template.hpp" | ||
#include "geometry/src/common_algebra_type.hpp" | ||
#include "geometry/src/detail/multivector_product.hpp" | ||
#include "geometry/src/detail/pending_dimensions_list.hpp" | ||
#include "geometry/type_metaprogramming.hpp" | ||
|
||
#include <type_traits> | ||
|
||
namespace geometry { | ||
namespace detail { | ||
|
||
inline constexpr class | ||
{ | ||
public: | ||
template < | ||
class T1, | ||
class T2, | ||
class D1 = std::decay_t<typename T1::eval_type>, | ||
class D2 = std::decay_t<typename T2::eval_type>, | ||
class Algebra = common_algebra_type_t<D1, D2>, | ||
class L = detail::pending_dimensions_list_t<D1, D2>, | ||
class R = | ||
typename tmp::convert_to_sequence_t<L, Algebra::template reified_blade>::type, | ||
int k = tmp::convert_to_sequence_t< | ||
L, | ||
Algebra::template reified_blade_coefficient>::value> | ||
constexpr auto | ||
operator()(expression_template::op<expression_template::multiplies, T1, T2>) | ||
const -> std::bool_constant< | ||
(R::grade != | ||
std::max(D1::grade, D2::grade) - std::min(D1::grade, D2::grade)) or | ||
(k == 0)> | ||
{ | ||
return {}; | ||
} | ||
} non_grade_contracting{}; | ||
|
||
} // namespace detail | ||
|
||
/// interior product | ||
/// | ||
/// @{ | ||
|
||
inline constexpr auto interior_product = // | ||
detail::multivector_product_with( // | ||
detail::non_grade_contracting, | ||
[](auto algebra) { | ||
return typename decltype(algebra)::template blade<>{}; | ||
}); | ||
|
||
template <class T1, class T2, class A = common_algebra_type_t<T1, T2>> | ||
[[nodiscard]] | ||
constexpr auto | ||
operator|(const T1& x, const T2& y) | ||
{ | ||
return interior_product(x, y); | ||
} | ||
|
||
/// @} | ||
|
||
} // namespace geometry |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#include "geometry/geometry.hpp" | ||
#include "skytest/skytest.hpp" | ||
|
||
#include "test/test_same.hpp" | ||
|
||
#include <cstddef> | ||
#include <tuple> | ||
#include <utility> | ||
|
||
auto main() -> int | ||
{ | ||
using namespace ::skytest::literals; | ||
using ::geometry::get; | ||
using ::geometry::test::same; | ||
using ::skytest::eq; | ||
using ::skytest::expect; | ||
using ::skytest::ne; | ||
|
||
"line orthogonal to point (2D)"_ctest = [] { | ||
using algebra = ::geometry::algebra<double, 2>; | ||
|
||
// https://bivector.net/PROJECTIVE_GEOMETRIC_ALGEBRA.pdf | ||
// section 7.1 | ||
|
||
constexpr auto x_hat = algebra::e<2, 0>; | ||
constexpr auto y_hat = algebra::e<0, 1>; | ||
constexpr auto E0 = algebra::e<1, 2>; | ||
|
||
const auto P = 0 * x_hat + 0 * y_hat + E0; | ||
|
||
// a line of the form | ||
// a * x + b * y + c = 0 | ||
// is represented as | ||
// a * e1 + b * e2 + c * e0 = 0 | ||
|
||
//using e0 = algebra::blade<0>; | ||
constexpr auto x = algebra::e<1>; | ||
constexpr auto y = algebra::e<2>; | ||
|
||
return expect(eq(x, y | P) and | ||
eq(y, x | P)); | ||
}; | ||
|
||
} |