Skip to content

Commit

Permalink
feat(sourcepp): add vector scale method
Browse files Browse the repository at this point in the history
  • Loading branch information
craftablescience committed Aug 3, 2024
1 parent 5ccae77 commit 61e6834
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions include/sourcepp/math/Vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,17 @@ struct Vec {
}

template<Arithmetic PO>
[[nodiscard]] constexpr P dot(const Vec<S, PO>& other) const {
[[nodiscard]] constexpr Vec scale(const Vec<S, PO>& other) const {
Vec out;
for (uint8_t i = 0; i < S; i++) {
out[i] = (*this)[i] * static_cast<P>(other[i]);
}
return out.sum();
return out;
}

template<Arithmetic PO>
[[nodiscard]] constexpr P dot(const Vec<S, PO>& other) const {
return this->scale(other).sum();
}

[[nodiscard]] constexpr Vec abs() const {
Expand Down

0 comments on commit 61e6834

Please sign in to comment.