diff options
author | Elisey Puzko <puzko.e02@gmail.com> | 2018-02-23 09:51:09 +0100 |
---|---|---|
committer | Elisey Puzko <puzko.e02@gmail.com> | 2018-02-23 09:51:09 +0100 |
commit | ab8278e3b61e009253e34d13d6706da7702dbb6c (patch) | |
tree | 83c8b0a731efff9b102be6506f0f20a5f31ea118 /src/Vector.hpp | |
parent | Quick fix. (diff) | |
download | AltCraft-ab8278e3b61e009253e34d13d6706da7702dbb6c.tar AltCraft-ab8278e3b61e009253e34d13d6706da7702dbb6c.tar.gz AltCraft-ab8278e3b61e009253e34d13d6706da7702dbb6c.tar.bz2 AltCraft-ab8278e3b61e009253e34d13d6706da7702dbb6c.tar.lz AltCraft-ab8278e3b61e009253e34d13d6706da7702dbb6c.tar.xz AltCraft-ab8278e3b61e009253e34d13d6706da7702dbb6c.tar.zst AltCraft-ab8278e3b61e009253e34d13d6706da7702dbb6c.zip |
Diffstat (limited to 'src/Vector.hpp')
-rw-r--r-- | src/Vector.hpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/Vector.hpp b/src/Vector.hpp index 5795db2..aa79ef0 100644 --- a/src/Vector.hpp +++ b/src/Vector.hpp @@ -31,6 +31,24 @@ struct Vector3 { std::swap(z, rhs.z); } + T dot(const Vector3 &rhs) const { + return x*rhs.x + y*rhs.y + z*rhs.z; + } + + double cosBetween(const Vector3<T> &rhs) const { + return dot(rhs) / GetLength() / rhs.GetLength(); + } + + Vector3<double> normalize() { + auto length = GetLength(); + + return Vector3<double> ( + x / length, + y / length, + z / length + ); + } + Vector3 &operator=(Vector3 rhs) noexcept { rhs.swap(*this); return *this; @@ -68,6 +86,14 @@ struct Vector3 { ); } + Vector3 operator-() const { + return Vector3<T> ( + -x, + -y, + -z + ); + } + Vector3 operator*(const Vector3 &rhs) const { return Vector3<T>( x * rhs.x, |