36 template < std::
size_t N >
37 using line = std::array< point< N >, 2 >;
40 template < std::
size_t N >
44 float const length_squared =
length2_of( direction );
45 if ( length_squared == 0.f )
47 float projection_dist =
dot( p - l[0], direction );
48 projection_dist /= length_squared;
49 projection_dist =
std::clamp( projection_dist, 0.f, 1.f );
51 point< N > const closest_p = l[0] + projection_dist * direction;
56 template < std::
size_t N >
Class implementing multidimensional point in coordinate system of dimension N.
Definition: point.h:36
MIT License.
Definition: impl.h:31
std::array< point< N >, 2 > line
Definition: line.h:37
constexpr float dot(quaternion const &q, quaternion const &s)
Definition: quaternion.h:101
constexpr auto length2_of(vec_point_base< Derived, N > const &a)
Returns squared distance of A from [0,0,0], this is a squared length of vector represented by A.
Definition: vec_point_base.h:192
constexpr T const & clamp(T const &x, min_max< T > const &mm, Compare &&comp)
Definition: min_max.h:69
constexpr float distance_of(line< N > const &l, point< N > const &p)
Definition: line.h:41