Added scalar addition / subtraction
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
// will evaluate to true
|
||||
#include <cmath>
|
||||
#include <type_traits>
|
||||
#include <string>
|
||||
|
||||
template <typename Type>
|
||||
V3D<Type>::V3D(const Matrix<1, 3> &other)
|
||||
@@ -60,12 +61,24 @@ void V3D<Type>::operator=(const V3D<Type> &other)
|
||||
this->z = other.z;
|
||||
}
|
||||
|
||||
template <typename Type>
|
||||
V3D<Type> V3D<Type>::operator+(Type other) const
|
||||
{
|
||||
return V3D<Type>{this->x + other, this->y + other, this->z + other};
|
||||
}
|
||||
|
||||
template <typename Type>
|
||||
V3D<Type> V3D<Type>::operator+(const V3D<Type> &other) const
|
||||
{
|
||||
return V3D<Type>{this->x + other.x, this->y + other.y, this->z + other.z};
|
||||
}
|
||||
|
||||
template <typename Type>
|
||||
V3D<Type> V3D<Type>::operator-(Type other) const
|
||||
{
|
||||
return V3D<Type>{this->x - other, this->y - other, this->z - other};
|
||||
}
|
||||
|
||||
template <typename Type>
|
||||
V3D<Type> V3D<Type>::operator-(const V3D<Type> &other) const
|
||||
{
|
||||
@@ -84,6 +97,13 @@ V3D<Type> V3D<Type>::operator/(Type scalar) const
|
||||
return V3D<Type>{this->x / scalar, this->y / scalar, this->z / scalar};
|
||||
}
|
||||
|
||||
template <typename Type>
|
||||
V3D<Type> &V3D<Type>::operator+=(Type other)
|
||||
{
|
||||
*this = *this + other;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename Type>
|
||||
V3D<Type> &V3D<Type>::operator+=(const V3D<Type> &other)
|
||||
{
|
||||
@@ -91,6 +111,13 @@ V3D<Type> &V3D<Type>::operator+=(const V3D<Type> &other)
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename Type>
|
||||
V3D<Type> &V3D<Type>::operator-=(Type other)
|
||||
{
|
||||
*this = *this - other;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename Type>
|
||||
V3D<Type> &V3D<Type>::operator-=(const V3D<Type> &other)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user