diff --git a/geom/segment.hpp b/geom/segment.hpp index 632ffbc2..0cb77b5e 100644 --- a/geom/segment.hpp +++ b/geom/segment.hpp @@ -64,6 +64,25 @@ namespace cruft::geom { } + /// Returns the un-normalised direction of the segment from its start to + /// end components. ie, `a' to `b'. + template + cruft::vector + udirection (segment const &val) + { + return val.b - val.a; + } + + + /// Returns the normalised direction of the segment. + template + cruft::vector + ndirection (segment const &val) + { + return normalised (udirection (val)); + } + + using segment2i = segment<2,int>; using segment3i = segment<3,int>;