geom/segment: add normalised and unnormalised direction queries
This commit is contained in:
parent
3baf7c6e94
commit
4cf6bb292b
@ -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 <size_t S, typename T>
|
||||||
|
cruft::vector<S,T>
|
||||||
|
udirection (segment<S,T> const &val)
|
||||||
|
{
|
||||||
|
return val.b - val.a;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// Returns the normalised direction of the segment.
|
||||||
|
template <size_t S, typename T>
|
||||||
|
cruft::vector<S,T>
|
||||||
|
ndirection (segment<S,T> const &val)
|
||||||
|
{
|
||||||
|
return normalised (udirection (val));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
using segment2i = segment<2,int>;
|
using segment2i = segment<2,int>;
|
||||||
using segment3i = segment<3,int>;
|
using segment3i = segment<3,int>;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user