Commit 24aa8407 authored by Aaron Grabowy's avatar Aaron Grabowy
Browse files

project for inf_cylinder + boundary

parent 5fcb2681
......@@ -367,13 +367,22 @@ template <class ScalarT>
// ============== project to inf_cylinder ==============
template <class ScalarT>
[[nodiscard]] constexpr pos<3, ScalarT> project(pos<3, ScalarT> const& p, inf_cylinder<3, ScalarT> const& c)
{
if (contains(c, p))
return p;
return project(p, boundary_of(c));
}
template <int D, class ScalarT>
[[nodiscard]] constexpr pos<D, ScalarT> project(pos<D, ScalarT> const& p, inf_cylinder<D, ScalarT> const& itube)
[[nodiscard]] constexpr pos<D, ScalarT> project(pos<D, ScalarT> const& p, inf_cylinder_boundary<D, ScalarT> const& c)
{
auto vec = p - itube.axis.pos;
auto h = dot(vec, itube.axis.dir);
auto point_on_axis = itube.axis[h];
return point_on_axis + tg::normalize_safe(p - point_on_axis) * itube.radius;
auto vec = p - c.axis.pos;
auto h = dot(vec, c.axis.dir);
auto point_on_axis = c.axis[h];
return point_on_axis + tg::normalize_safe(p - point_on_axis) * c.radius;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment