Skip to content

Commit

Permalink
add optional API
Browse files Browse the repository at this point in the history
  • Loading branch information
markaren committed Feb 27, 2024
1 parent 2af263f commit 680df91
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions include/threepp/math/Line3.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
17 changes: 17 additions & 0 deletions src/threepp/math/Line3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_);
Expand Down

0 comments on commit 680df91

Please sign in to comment.