Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- class ulong64;
- template<typename atype> class aeVector4 {
- public:
- aeVector4();
- aeVector4(atype xin, atype yin, atype zin, atype hin);
- virtual ~aeVector4();
- // standard arithmetic operators
- inline aeVector4<atype> operator+(const aeVector4<atype>& param);
- inline aeVector4<atype> operator-(const aeVector4<atype>& param);
- inline aeVector4<atype> operator*(const aeVector4<atype>& param);
- inline aeVector4<atype> operator/(const aeVector4<atype>& param);
- inline aeVector4<atype> operator%(const aeVector4<atype>& param);
- inline aeVector4<atype> operator+=(const aeVector4<atype>& param);
- inline aeVector4<atype> operator-=(const aeVector4<atype>& param);
- inline aeVector4<atype> operator*=(const aeVector4<atype>& param);
- inline aeVector4<atype> operator/=(const aeVector4<atype>& param);
- inline aeVector4<atype> operator%=(const aeVector4<atype>& param);
- // bitwise operators
- inline aeVector4<atype> operator~();;
- inline aeVector4<atype> operator&(const aeVector4<atype>& param);
- inline aeVector4<atype> operator|(const aeVector4<atype>& param);
- inline aeVector4<atype> operator^(const aeVector4<atype>& param);
- inline aeVector4<atype> operator<<(const aeVector4<atype>& param);
- inline aeVector4<atype> operator>>(const aeVector4<atype>& param);
- inline aeVector4<atype> operator&=(const aeVector4<atype>& param);
- inline aeVector4<atype> operator^=(const aeVector4<atype>& param);
- inline aeVector4<atype> operator|=(const aeVector4<atype>& param);
- inline aeVector4<atype> operator<<=(const aeVector4<atype>& param);
- inline aeVector4<atype> operator>>=(const aeVector4<atype>& param);
- // standard arithmetic operators
- inline aeVector4<atype> operator+(const atype& param);
- inline aeVector4<atype> operator-(const atype& param);
- inline aeVector4<atype> operator*(const atype& param);
- inline aeVector4<atype> operator/(const atype& param);
- inline aeVector4<atype> operator%(const atype& param);
- inline aeVector4<atype> operator+=(const atype& param);
- inline aeVector4<atype> operator-=(const atype& param);
- inline aeVector4<atype> operator*=(const atype& param);
- inline aeVector4<atype> operator/=(const atype& param);
- inline aeVector4<atype> operator%=(const atype& param);
- inline aeVector4<atype> operator/(const atype val) const;
- // bitwise operators
- inline aeVector4<atype> operator&(const atype& param);
- inline aeVector4<atype> operator|(const atype& param);
- inline aeVector4<atype> operator^(const atype& param);
- inline aeVector4<atype> operator<<(const atype& param);
- inline aeVector4<atype> operator>>(const atype& param);
- inline aeVector4<atype> operator&=(const atype& param);
- inline aeVector4<atype> operator^=(const atype& param);
- inline aeVector4<atype> operator|=(const atype& param);
- inline aeVector4<atype> operator<<=(const atype& param);
- inline aeVector4<atype> operator>>=(const atype& param);
- // non standard
- inline aeVector4<atype> operator-(aeVector4<atype> param) const;
- inline aeVector4<atype> operator+(aeVector4<atype> param) const;
- // Math Functions;
- inline atype Dot(const aeVector4<atype> param) const;
- inline atype GetLength() const;
- inline atype SquaredLength() const;
- inline aeVector4<atype> GetNormalized() const;
- inline aeVector4<atype> Normalize();
- // Get position
- inline Vector3 GetVector3() const;
- inline atype GetHeight() const;
- // three default values
- atype x;
- atype y;
- atype z;
- atype h;
- };
- // code
- // constructor
- template<typename atype> aeVector4<atype>::aeVector4() :
- x(0), y(0), z(0), h(0) {
- return;
- }
- // constructor
- template<typename atype> aeVector4<atype>::aeVector4(atype inx, atype iny, atype inz, atype inh) :
- x(inx), y(iny), z(inz), h(inh) {
- return;
- }
- // deconstructor
- template<typename atype> aeVector4<atype>::~aeVector4() {
- return;
- }
- template<typename atype> aeVector4<atype> aeVector4<atype>::operator/(const atype val) const
- {
- return aeVector4(x / val, y / val, z / val, h/val);
- }
- // operator functions
- template<typename atype> aeVector4<atype> aeVector4<atype>::operator+(
- const aeVector4<atype>& param) {
- // create a temp
- aeVector4<atype> temp;
- // add values
- temp.x = x + param.x;
- temp.y = y + param.y;
- temp.z = z + param.z;
- temp.h = h + param.h;
- return temp;
- }
- // operator functions
- template<typename atype> aeVector4<atype> aeVector4<atype>::operator-(
- const aeVector4<atype>& param) {
- // create a temp
- aeVector4<atype> temp;
- // add values
- temp.x = x - param.x;
- temp.y = y - param.y;
- temp.z = z - param.z;
- temp.h = h - param.h;
- return temp;
- }
- // operator functions
- template<typename atype> aeVector4<atype> aeVector4<atype>::operator*(
- const aeVector4<atype>& param) {
- // create a temp
- aeVector4<atype> temp;
- // add values
- temp.x = x * param.x;
- temp.y = y * param.y;
- temp.z = z * param.z;
- temp.h = h * param.h;
- return temp;
- }
- // operator functions
- template<typename atype> aeVector4<atype> aeVector4<atype>::operator/(
- const aeVector4<atype>& param) {
- // create a temp
- aeVector4<atype> temp;
- // add values
- temp.x = x / param.x;
- temp.y = y / param.y;
- temp.z = z / param.z;
- temp.h = h / param.h;
- return temp;
- }
- // operator functions
- template<typename atype> aeVector4<atype> aeVector4<atype>::operator%(
- const aeVector4<atype>& param) {
- // create a temp
- aeVector4<atype> temp;
- // add values
- temp.x = x % param.x;
- temp.y = y % param.y;
- temp.z = z % param.z;
- temp.h = h % param.h;
- return temp;
- }
- // bitwise operators
- // bitwise NOT
- template<typename atype> aeVector4<atype> aeVector4<atype>::operator~() {
- // add values
- ~x;
- ~y;
- ~z;
- ~h;
- return *this;
- }
- // bitwise AND
- template<typename atype> aeVector4<atype> aeVector4<atype>::operator&(
- const aeVector4<atype>& param) {
- // create a temp
- aeVector4<atype> temp;
- // add values
- temp.x = x & param.x;
- temp.y = y & param.y;
- temp.z = z & param.z;
- temp.h = h & param.h;
- return temp;
- }
- //bitwise OR
- template<typename atype> aeVector4<atype> aeVector4<atype>::operator|(
- const aeVector4<atype>& param) {
- // create a temp
- aeVector4<atype> temp;
- // add values
- temp.x = x | param.x;
- temp.y = y | param.y;
- temp.z = z | param.z;
- temp.h = h | param.h;
- return temp;
- }
- //bitwise XOR
- template<typename atype> aeVector4<atype> aeVector4<atype>::operator^(
- const aeVector4<atype>& param) {
- // create a temp
- aeVector4<atype> temp;
- // add values
- temp.x = x ^ param.x;
- temp.y = y ^ param.y;
- temp.z = z ^ param.z;
- temp.h = h ^ param.h;
- return temp;
- }
- //bitwise left
- template<typename atype> aeVector4<atype> aeVector4<atype>::operator<<(
- const aeVector4<atype>& param) {
- // create a temp
- aeVector4<atype> temp;
- // add values
- temp.x = x << param.x;
- temp.y = y << param.y;
- temp.z = z << param.z;
- temp.h = h << param.h;
- return temp;
- }
- // bitwise right
- template<typename atype> aeVector4<atype> aeVector4<atype>::operator>>(
- const aeVector4<atype>& param) {
- // create a temp
- aeVector4<atype> temp;
- // add values
- temp.x = x >> param.x;
- temp.y = y >> param.y;
- temp.z = z >> param.z;
- temp.h = h >> param.h;
- return temp;
- }
- //bitwise AND=
- template<typename atype> aeVector4<atype> aeVector4<atype>::operator&=(
- const aeVector4<atype>& param) {
- // create a temp
- aeVector4<atype> temp;
- // add values
- x &= param.x;
- y &= param.y;
- z &= param.z;
- h &= param.h;
- return *this;
- }
- // bitwise OR =
- template<typename atype> aeVector4<atype> aeVector4<atype>::operator|=(
- const aeVector4<atype>& param) {
- // create a temp
- aeVector4<atype> temp;
- // add values
- x |= param.x;
- y |= param.y;
- z |= param.z;
- h |= param.h;
- return *this;
- }
- // bitwise XOR =
- template<typename atype> aeVector4<atype> aeVector4<atype>::operator^=(
- const aeVector4<atype>& param) {
- // create a temp
- aeVector4<atype> temp;
- // add values
- x ^= param.x;
- y ^= param.y;
- z ^= param.z;
- h ^= param.h;
- return *this;
- }
- // bitwise left by x =
- template<typename atype> aeVector4<atype> aeVector4<atype>::operator<<=(
- const aeVector4<atype>& param) {
- x <<= param.x;
- y <<= param.y;
- z <<= param.z;
- h <<= param.h;
- return *this;
- }
- // bitwise right by x=
- template<typename atype> aeVector4<atype> aeVector4<atype>::operator>>=(
- const aeVector4<atype>& param) {
- x >>= param.x;
- y >>= param.y;
- z >>= param.z;
- h >>= param.h;
- return *this;
- }
- // operator functions
- template<typename atype> aeVector4<atype> aeVector4<atype>::operator+=(
- const aeVector4<atype>& param) {
- // add values
- x += param.x;
- y += param.y;
- z += param.z;
- h += param.h;
- return *this;
- }
- // operator functions
- template<typename atype> aeVector4<atype> aeVector4<atype>::operator-=(
- const aeVector4<atype>& param) {
- // create a temp
- // add values
- x -= param.x;
- y -= param.y;
- z -= param.z;
- h -= param.h;
- return *this;
- }
- // operator functions
- template<typename atype> aeVector4<atype> aeVector4<atype>::operator*=(
- const aeVector4<atype>& param) {
- // add values
- x *= param.x;
- y *= param.y;
- z *= param.z;
- h *= param.h;
- return *this;
- }
- // operator functions
- template<typename atype> aeVector4<atype> aeVector4<atype>::operator%=(
- const aeVector4<atype>& param) {
- // add values
- x %= param.x;
- y %= param.y;
- z %= param.z;
- h %= param.h;
- return *this;
- }
- // operator functions
- template<typename atype> aeVector4<atype> aeVector4<atype>::operator/=(
- const aeVector4<atype>& param) {
- // add values
- x /= param.x;
- y /= param.y;
- z /= param.z;
- h /= param.h;
- return *this;
- }
- // operator functions
- template<typename atype> aeVector4<atype> aeVector4<atype>::operator+(
- const atype& param) {
- // create a temp
- aeVector4<atype> temp;
- // add values
- temp.x = x + param;
- temp.y = y + param;
- temp.z = z + param;
- temp.h = h + param;
- return temp;
- }
- // operator functions
- template<typename atype> aeVector4<atype> aeVector4<atype>::operator-(
- const atype& param) {
- // create a temp
- aeVector4<atype> temp;
- // add values
- temp.x = x - param;
- temp.y = y - param;
- temp.z = z - param;
- temp.h = h - param;
- return temp;
- }
- // operator functions
- template<typename atype> aeVector4<atype> aeVector4<atype>::operator*(
- const atype& param) {
- // create a temp
- aeVector4<atype> temp;
- // add values
- temp.x = x * param;
- temp.y = y * param;
- temp.z = z * param;
- temp.h = h * param;
- return temp;
- }
- // operator functions
- template<typename atype> aeVector4<atype> aeVector4<atype>::operator/(
- const atype& param) {
- // create a temp
- aeVector4<atype> temp;
- // add values
- temp.x = x / param;
- temp.y = y / param;
- temp.z = z / param;
- temp.h = h / param;
- return temp;
- }
- // operator functions
- template<typename atype> aeVector4<atype> aeVector4<atype>::operator%(
- const atype& param) {
- // create a temp
- aeVector4<atype> temp;
- // add values
- temp.x = x % param;
- temp.y = y % param;
- temp.z = z % param;
- temp.h = h % param;
- return temp;
- }
- // bitwise AND
- template<typename atype> aeVector4<atype> aeVector4<atype>::operator&(
- const atype& param) {
- // create a temp
- aeVector4<atype> temp;
- // add values
- temp.x = x & param;
- temp.y = y & param;
- temp.z = z & param;
- temp.h = h & param;
- return temp;
- }
- //bitwise OR
- template<typename atype> aeVector4<atype> aeVector4<atype>::operator|(
- const atype& param) {
- // create a temp
- aeVector4<atype> temp;
- // add values
- temp.x = x | param;
- temp.y = y | param;
- temp.z = z | param;
- temp.h = h | param;
- return temp;
- }
- //bitwise XOR
- template<typename atype> aeVector4<atype> aeVector4<atype>::operator^(
- const atype& param) {
- // create a temp
- aeVector4<atype> temp;
- // add values
- temp.x = x ^ param;
- temp.y = y ^ param;
- temp.z = z ^ param;
- temp.h = h ^ param;
- return temp;
- }
- //bitwise left
- template<typename atype> aeVector4<atype> aeVector4<atype>::operator<<(
- const atype& param) {
- // create a temp
- aeVector4<atype> temp;
- // add values
- temp.x = x << param;
- temp.y = y << param;
- temp.z = z << param;
- temp.h = h << param;
- return temp;
- }
- // bitwise right
- template<typename atype> aeVector4<atype> aeVector4<atype>::operator>>(
- const atype& param) {
- // create a temp
- aeVector4<atype> temp;
- // add values
- temp.x = x >> param;
- temp.y = y >> param;
- temp.z = z >> param;
- temp.h = h >> param;
- return temp;
- }
- //bitwise AND=
- template<typename atype> aeVector4<atype> aeVector4<atype>::operator&=(
- const atype& param) {
- // create a temp
- aeVector4<atype> temp;
- // add values
- x &= param;
- y &= param;
- z &= param;
- h &= param;
- return *this;
- }
- // bitwise OR =
- template<typename atype> aeVector4<atype> aeVector4<atype>::operator|=(
- const atype& param) {
- // create a temp
- aeVector4<atype> temp;
- // add values
- x |= param;
- y |= param;
- z |= param;
- h |= param;
- return *this;
- }
- // bitwise XOR =
- template<typename atype> aeVector4<atype> aeVector4<atype>::operator^=(
- const atype& param) {
- // create a temp
- aeVector4<atype> temp;
- // add values
- x ^= param;
- y ^= param;
- z ^= param;
- h ^= param;
- return *this;
- }
- // bitwise left by x =
- template<typename atype> aeVector4<atype> aeVector4<atype>::operator<<=(
- const atype& param) {
- x <<= param;
- y <<= param;
- z <<= param;
- return *this;
- }
- // bitwise right by x=
- template<typename atype> aeVector4<atype> aeVector4<atype>::operator>>=(
- const atype& param) {
- x >>= param;
- y >>= param;
- z >>= param;
- h >>= param;
- return *this;
- }
- // operator functions
- template<typename atype> aeVector4<atype> aeVector4<atype>::operator+=(
- const atype& param) {
- // add values
- x += param;
- y += param;
- z += param;
- h += param;
- return *this;
- }
- // operator functions
- template<typename atype> aeVector4<atype> aeVector4<atype>::operator-=(
- const atype& param) {
- // create a temp
- // add values
- x -= param;
- y -= param;
- z -= param;
- return *this;
- }
- // operator functions
- template<typename atype> aeVector4<atype> aeVector4<atype>::operator*=(
- const atype& param) {
- // add values
- x *= param;
- y *= param;
- z *= param;
- h *= param;
- return *this;
- }
- // operator functions
- template<typename atype> aeVector4<atype> aeVector4<atype>::operator%=(
- const atype& param) {
- // add values
- x %= param;
- y %= param;
- z %= param;
- h %= param;
- return *this;
- }
- // operator functions
- template<typename atype> aeVector4<atype> aeVector4<atype>::operator/=(
- const atype& param) {
- // add values
- x /= param;
- y /= param;
- z /= param;
- h /= param;
- return *this;
- }
- // operator functions
- template<typename atype> aeVector4<atype> aeVector4<atype>::operator-(
- aeVector4<atype> param) const {
- // create a temp
- aeVector4<atype> temp;
- // add values
- temp.x = x - param.x;
- temp.y = y - param.y;
- temp.z = z - param.z;
- temp.h = h - param.h;
- return temp;
- }
- // operator functions
- template<typename atype> aeVector4<atype> aeVector4<atype>::operator+(
- aeVector4<atype> param) const {
- // create a temp
- aeVector4<atype> temp;
- // add values
- temp.x = x + param;
- temp.y = y + param;
- temp.z = z + param;
- temp.h = h + param;
- return temp;
- }
- template<typename atype> Vector3 aeVector4<atype>::GetVector3() const
- {
- return Vector3((float)x, float(y), float(z));
- }
- template<typename atype> atype aeVector4<atype>::Dot(const aeVector4<atype> param) const
- {
- return x*param.x+y*param.y+z*param.z;
- }
- template<typename atype> atype aeVector4<atype>::SquaredLength() const
- {
- return Dot(*this);
- }
- template<typename atype> atype aeVector4<atype>::GetHeight() const
- {
- return h;
- }
- template<typename atype> atype aeVector4<atype>::GetLength() const
- {
- return sqrt(SquaredLength());
- }
- template<typename atype> aeVector4<atype> aeVector4<atype>::GetNormalized() const
- {
- if (SquaredLength() == 0)
- return *this;
- return *this / GetLength();
- }
- template<typename atype> aeVector4<atype> aeVector4<atype>::Normalize()
- {
- if (SquaredLength() == 0)
- return *this;
- return *this /= GetLength();
- }
Advertisement
Add Comment
Please, Sign In to add comment