Added dot product
parent
128fc2f9dc
commit
e50cc74bf3
|
@ -40,6 +40,7 @@ namespace blt {
|
||||||
[[nodiscard]] inline float x() const {return elements[0];}
|
[[nodiscard]] inline float x() const {return elements[0];}
|
||||||
[[nodiscard]] inline float y() const {return elements[1];}
|
[[nodiscard]] inline float y() const {return elements[1];}
|
||||||
[[nodiscard]] inline float z() const {return elements[2];}
|
[[nodiscard]] inline float z() const {return elements[2];}
|
||||||
|
[[nodiscard]] inline float w() const {return elements[3];}
|
||||||
|
|
||||||
inline float& operator[](int index) {
|
inline float& operator[](int index) {
|
||||||
return elements[index];
|
return elements[index];
|
||||||
|
@ -103,6 +104,16 @@ namespace blt {
|
||||||
elements[i] -= f;
|
elements[i] -= f;
|
||||||
return *this;
|
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>
|
template<unsigned long size>
|
||||||
|
|
Loading…
Reference in New Issue