diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/maths.h | 9 | ||||
| -rw-r--r-- | lib/ray.h | 3 | ||||
| -rw-r--r-- | lib/triangle.h | 2 | 
3 files changed, 10 insertions, 4 deletions
| diff --git a/lib/maths.h b/lib/maths.h index 17ca795..3d4f440 100644 --- a/lib/maths.h +++ b/lib/maths.h @@ -111,6 +111,13 @@ difference(const glm::vec<D, T, Q> & globalA, const glm::vec<D, T, Q> & globalB)  	return globalA - globalB;  } +template<glm::length_t D, Arithmetic T, glm::qualifier Q = glm::defaultp> +constexpr auto +distance(const glm::vec<D, T, Q> & pointA, const glm::vec<D, T, Q> & pointB) +{ +	return glm::length(difference(pointA, pointB)); +} +  glm::mat4 flat_orientation(const Rotation3D & diff);  namespace { @@ -498,7 +505,7 @@ operator"" _degrees(long double degrees)  // Late implementations due to dependencies  template<typename T, glm::qualifier Q>  constexpr ArcSegment<T, Q>::ArcSegment(PointType centre, PointType ep0, PointType ep1) : -	Arc {centre, ep0, ep1}, centre {centre}, ep0 {ep0}, ep1 {ep1}, radius {glm::length(difference(centre, ep0))} +	Arc {centre, ep0, ep1}, centre {centre}, ep0 {ep0}, ep1 {ep1}, radius {::distance(centre, ep0)}  {  } @@ -27,8 +27,7 @@ public:  		const auto n2 = crossProduct(direction, n);  		const auto c1 = p1 + PositionType((glm::dot(RelativePosition3D(start - p1), n2) / glm::dot(d1, n2)) * d1);  		const auto difflength = glm::length(diff); -		if (glm::length(RelativePosition3D(c1 - p1)) > difflength -				|| glm::length(RelativePosition3D(c1 - e1)) > difflength) { +		if (::distance(c1, p1) > difflength || ::distance(c1, e1) > difflength) {  			return std::numeric_limits<typename PositionType::value_type>::infinity();  		}  		return static_cast<PositionType::value_type>(glm::abs(glm::dot(n, RelativePosition3D(p1 - start)))); diff --git a/lib/triangle.h b/lib/triangle.h index d5547ab..e430653 100644 --- a/lib/triangle.h +++ b/lib/triangle.h @@ -48,7 +48,7 @@ struct Triangle : public glm::vec<3, glm::vec<Dim, T, Q>> {  	[[nodiscard]] constexpr auto  	height()  	{ -		return (area() * 2) / glm::length(difference(p(0), p(1))); +		return (area() * 2) / ::distance(p(0), p(1));  	}  	[[nodiscard]] constexpr Normal3D | 
