Added dot product

v1
Brett 2023-02-11 15:25:28 -05:00
parent 128fc2f9dc
commit e50cc74bf3
1 changed files with 11 additions and 0 deletions

View File

@ -40,6 +40,7 @@ namespace blt {
[[nodiscard]] inline float x() const {return elements[0];}
[[nodiscard]] inline float y() const {return elements[1];}
[[nodiscard]] inline float z() const {return elements[2];}
[[nodiscard]] inline float w() const {return elements[3];}
inline float& operator[](int index) {
return elements[index];
@ -103,6 +104,16 @@ namespace blt {
elements[i] -= f;
return *this;
}
/**
* performs the dot product of left * right
*/
static inline float dot(const vec<size>& left, const vec<size>& right) {
float dot = 0;
for (int i = 0; i < size; i++)
dot += left[i] * right[i];
return dot;
}
};
template<unsigned long size>