scalar vector math
This commit is contained in:
parent
1173d15b2f
commit
bb85af197c
1 changed files with 57 additions and 0 deletions
|
|
@ -209,6 +209,63 @@ namespace Crafter {
|
|||
}
|
||||
}
|
||||
|
||||
template <typename BT>
|
||||
constexpr Vector<T, Len, Aligment> operator+(BT b) const {
|
||||
Vector<T, Len, Aligment> resultVector;
|
||||
for(std::uint32_t i = 0; i < Len; i++) {
|
||||
resultVector.v[i] = this->v[i] + b;
|
||||
}
|
||||
return resultVector;
|
||||
}
|
||||
template <typename BT>
|
||||
constexpr Vector<T, Len, Aligment> operator-(BT b) const {
|
||||
Vector<T, Len, Aligment> resultVector;
|
||||
for(std::uint32_t i = 0; i < Len; i++) {
|
||||
resultVector.v[i] = this->v[i] - b;
|
||||
}
|
||||
return resultVector;
|
||||
}
|
||||
template <typename BT>
|
||||
constexpr Vector<T, Len, Aligment> operator*(BT b) const {
|
||||
Vector<T, Len, Aligment> resultVector;
|
||||
for(std::uint32_t i = 0; i < Len; i++) {
|
||||
resultVector.v[i] = this->v[i] * b;
|
||||
}
|
||||
return resultVector;
|
||||
}
|
||||
template <typename BT>
|
||||
constexpr Vector<T, Len, Aligment> operator/(BT b) const {
|
||||
Vector<T, Len, Aligment> resultVector;
|
||||
for(std::uint32_t i = 0; i < Len; i++) {
|
||||
resultVector.v[i] = this->v[i] / b;
|
||||
}
|
||||
return resultVector;
|
||||
}
|
||||
template <typename BT>
|
||||
constexpr void operator+=(BT b){
|
||||
for(std::uint32_t i = 0; i < Len; i++) {
|
||||
this->v[i] += b;
|
||||
}
|
||||
}
|
||||
template <typename BT>
|
||||
constexpr void operator-=(BT b){
|
||||
for(std::uint32_t i = 0; i < Len; i++) {
|
||||
this->v[i] -= b;
|
||||
}
|
||||
}
|
||||
template <typename BT>
|
||||
constexpr void operator*=(BT b){
|
||||
for(std::uint32_t i = 0; i < Len; i++) {
|
||||
this->v[i] *= b;
|
||||
}
|
||||
}
|
||||
template <typename BT>
|
||||
constexpr void operator/=(BT b){
|
||||
for(std::uint32_t i = 0; i < Len; i++) {
|
||||
this->v[i] /= b;
|
||||
}
|
||||
}
|
||||
|
||||
constexpr void Normalize() {
|
||||
float fLength = Length();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue