diff --git a/include/threepp/math/Line3.hpp b/include/threepp/math/Line3.hpp index 56b8df3e..f8f24223 100644 --- a/include/threepp/math/Line3.hpp +++ b/include/threepp/math/Line3.hpp @@ -22,8 +22,12 @@ namespace threepp { void getCenter(Vector3& target) const; + [[nodiscard]] Vector3 getCenter() const; + void delta(Vector3& target) const; + [[nodiscard]] Vector3 delta() const; + [[nodiscard]] float distanceSq() const; [[nodiscard]] float distance() const; diff --git a/src/threepp/math/Line3.cpp b/src/threepp/math/Line3.cpp index 1a2e4113..94542ea2 100644 --- a/src/threepp/math/Line3.cpp +++ b/src/threepp/math/Line3.cpp @@ -41,11 +41,28 @@ void Line3::getCenter(Vector3& target) const { target.addVectors(this->start_, this->end_).multiplyScalar(0.5f); } +Vector3 Line3::getCenter() const { + + Vector3 target; + getCenter(target); + + return target; +} + void Line3::delta(Vector3& target) const { target.subVectors(this->end_, this->start_); } +Vector3 Line3::delta() const { + + Vector3 target; + delta(target); + + return target; +} + + float Line3::distanceSq() const { return this->start_.distanceToSquared(this->end_);