diff --git a/include/bx/inline/math.inl b/include/bx/inline/math.inl index 3d83668..f9cf158 100644 --- a/include/bx/inline/math.inl +++ b/include/bx/inline/math.inl @@ -499,6 +499,17 @@ namespace bx return sqrt(dot(_a, _a) ); } + inline BX_CONST_FUNC float distanceSq(const Vec3 _a, const Vec3 _b) + { + const Vec3 ba = sub(_b, _a); + return dot(ba, ba); + } + + inline BX_CONST_FUNC float distance(const Vec3 _a, const Vec3 _b) + { + return length(sub(_b, _a) ); + } + inline BX_CONSTEXPR_FUNC Vec3 lerp(const Vec3 _a, const Vec3 _b, float _t) { return diff --git a/include/bx/math.h b/include/bx/math.h index 78b0360..f606392 100644 --- a/include/bx/math.h +++ b/include/bx/math.h @@ -333,6 +333,12 @@ namespace bx /// BX_CONST_FUNC float length(const Vec3 _a); + /// + BX_CONST_FUNC float distanceSq(const Vec3 _a, const Vec3 _b); + + /// + BX_CONST_FUNC float distance(const Vec3 _a, const Vec3 _b); + /// BX_CONSTEXPR_FUNC Vec3 lerp(const Vec3 _a, const Vec3 _b, float _t);