Skip to content
Snippets Groups Projects
Commit a23bdb40 authored by Julius Nehring-Wirxel's avatar Julius Nehring-Wirxel
Browse files

Merge branch 'develop' of...

parents b6fc632a 1a093c6c
Branches
No related tags found
No related merge requests found
......@@ -3,4 +3,5 @@
#include <typed-geometry/functions/random/gaussian.hh>
#include <typed-geometry/functions/random/random.hh>
#include <typed-geometry/functions/random/random_choice.hh>
#include <typed-geometry/functions/random/shuffle.hh>
#include <typed-geometry/functions/random/uniform.hh>
......@@ -540,6 +540,14 @@ template <class ScalarT>
return {};
}
template <class ScalarT>
[[nodiscard]] constexpr pos<2, ScalarT> intersection(line<2, ScalarT> const& l0, line<2, ScalarT> const& l1)
{
auto M = tg::mat<2, 2, ScalarT>::from_cols(l0.dir, -l1.dir);
auto t = inverse(M) * (l1.pos - l0.pos);
return l0[t.x];
}
template <int D, class ScalarT>
[[nodiscard]] constexpr optional<aabb<D, ScalarT>> intersection(aabb<D, ScalarT> const& a, aabb<D, ScalarT> const& b)
{
......
#pragma once
#include <typed-geometry/types/span.hh>
namespace tg
{
template <class Rng, class T>
constexpr void shuffle(Rng& rng, span<T> range)
{
for (size_t i = 1; i < range.size(); ++i)
{
auto j = rng() % (i + 1);
if (i != j)
detail::swap(range[i], range[j]);
}
}
template <class Rng, class Range>
constexpr void shuffle(Rng& rng, Range& range)
{
shuffle(rng, tg::span(range));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment