123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- #pragma once
- #include "Vec3.h"
- namespace Framework
- {
- template<typename T>
-
- class Ebene3D
- {
- public:
- T x;
- T y;
- T z;
- T w;
-
-
- inline Ebene3D()
- : x((T)0),
- y((T)0),
- z((T)0),
- w((T)0)
- {}
-
-
-
-
-
-
- inline Ebene3D(T x, T y, T z, T w)
- : x(x),
- y(y),
- z(z),
- w(w)
- {}
-
-
- inline Ebene3D(const Ebene3D& vect)
- : Ebene3D(vect.x, vect.y, vect.z, vect.w)
- {}
-
- inline Ebene3D& normalize()
- {
- const T length = len();
- x /= length;
- y /= length;
- z /= length;
- w /= length;
- return *this;
- }
-
-
- inline Ebene3D& Swap(Ebene3D& vect)
- {
- const Ebene3D tmp = vect;
- vect = *this;
- *this = tmp;
- return *this;
- }
-
-
- inline Ebene3D operator=(const Ebene3D& r)
- {
- x = r.x;
- y = r.y;
- z = r.z;
- w = r.w;
- return *this;
- }
-
-
- inline Ebene3D operator+=(const Ebene3D& r)
- {
- x += r.x;
- y += r.y;
- z += r.z;
- w += r.w;
- return *this;
- }
-
-
- inline Ebene3D operator-=(const Ebene3D& r)
- {
- x -= r.x;
- y -= r.y;
- z -= r.z;
- w -= r.w;
- return *this;
- }
-
-
- inline Ebene3D operator*=(const T& r)
- {
- x *= r;
- y *= r;
- z *= r;
- w *= r;
- return *this;
- }
-
-
- inline Ebene3D operator/=(const T& r)
- {
- x /= r;
- y /= r;
- z /= r;
- w /= r;
- return *this;
- }
- template<typename T2>
-
- inline operator Ebene3D<T2>() const
- {
- return {(T2)x, (T2)y, (T2)z, (T2)w};
- }
-
- inline T lenSq() const
- {
- return x * x + y * y + z * z;
- }
-
- inline T len() const
- {
- return sqrt(lenSq());
- }
-
-
- inline T operator*(const Vec3<T>& r) const
- {
- return x * r.x + y * r.y + z * r.z + w;
- }
-
-
- inline Ebene3D operator+(const Ebene3D& r) const
- {
- return Vec4(*this) += r;
- }
-
-
- inline Ebene3D operator-(const Ebene3D& r) const
- {
- return Ebene3D(*this) -= r;
- }
-
-
- inline Ebene3D operator*(const T& r) const
- {
- return Ebene3D(*this) *= r;
- }
-
-
- inline Ebene3D operator/(const T& r) const
- {
- return Ebene3D(*this) /= r;
- }
-
-
- inline bool operator==(const Ebene3D& r) const
- {
- return x == r.x && y == r.y && z == r.z && w == r.w;
- }
-
-
- inline bool operator!=(const Ebene3D& r) const
- {
- return !(*this == r);
- }
- };
- }
|