vector_4d.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053 #ifndef LASS_GUARDIAN_OF_INCLUSION_PRIM_VECTOR_4D_H
00054 #define LASS_GUARDIAN_OF_INCLUSION_PRIM_VECTOR_4D_H
00055
00056
00057
00058
00059 #include "prim_common.h"
00060 #include "../io/xml_o_stream.h"
00061
00062
00063 namespace lass
00064 {
00065
00066 namespace prim
00067 {
00068
00069 template<typename T>
00070 struct Vector4D
00071 {
00072 typedef Vector4D<T> TSelf;
00073
00074 typedef typename util::CallTraits<T>::TValue TValue;
00075 typedef typename util::CallTraits<T>::TParam TParam;
00076 typedef typename util::CallTraits<T>::TReference TReference;
00077 typedef typename util::CallTraits<T>::TConstReference TConstReference;
00078 typedef typename num::NumTraits<T> TNumTraits;
00079
00080 enum { dimension = 4 };
00081
00082 template <typename U> struct Rebind
00083 {
00084 typedef Vector4D<U> Type;
00085 };
00086
00087
00088
00089
00090 TValue x;
00091 TValue y;
00092 TValue z;
00093 TValue w;
00094
00095
00096
00097
00098 Vector4D();
00099 Vector4D(TParam x, TParam y, TParam z, TParam w);
00100 template <typename U> explicit Vector4D(const Vector4D<U>& other);
00101 template <typename U> Vector4D(const U& x, const U& y, const U& z, const U& w);
00102
00103 typename Vector4D::TConstReference operator[](size_t index) const;
00104 typename Vector4D::TReference operator[](size_t index) ;
00105 typename Vector4D::TConstReference at(signed index) const;
00106 typename Vector4D::TReference at(signed index);
00107
00108 const Vector4D<T>& operator+() const;
00109 const Vector4D<T> operator-() const;
00110 Vector4D<T>& operator+=(const Vector4D<T>& other);
00111 Vector4D<T>& operator-=(const Vector4D<T>& other);
00112 Vector4D<T>& operator*=(const Vector4D<T>& other);
00113 Vector4D<T>& operator/=(const Vector4D<T>& other);
00114 Vector4D<T>& operator+=(TParam other);
00115 Vector4D<T>& operator-=(TParam other);
00116 Vector4D<T>& operator*=(TParam other);
00117 Vector4D<T>& operator/=(TParam other);
00118
00119 const bool isZero() const;
00120 const bool isNaN() const;
00121 const TValue squaredNorm() const;
00122 const TValue norm() const;
00123 const Vector4D<T> normal() const;
00124 const Vector4D<T> reciprocal() const;
00125 const Vector4D<T> project(const Vector4D<T>& other) const;
00126 const Vector4D<T> reject(const Vector4D<T>& other) const;
00127 const Vector4D<T> reflect(const Vector4D<T>& other) const;
00128 const Vector4D<T> transform(T (*op)(T)) const;
00129
00130 void normalize();
00131 };
00132
00133 template<typename T> typename Vector4D<T>::TValue dot(const Vector4D<T>& a, const Vector4D<T>& b);
00134
00135 template<typename T> bool operator==(const Vector4D<T>& a, const Vector4D<T>& b);
00136 template<typename T> bool operator!=(const Vector4D<T>& a, const Vector4D<T>& b);
00137
00138 template<typename T> Vector4D<T> operator+(const Vector4D<T>& a, const Vector4D<T>& b);
00139 template<typename T> Vector4D<T> operator-(const Vector4D<T>& a, const Vector4D<T>& b);
00140 template<typename T> Vector4D<T> operator*(const Vector4D<T>& a, const Vector4D<T>& b);
00141 template<typename T> Vector4D<T> operator/(const Vector4D<T>& a, const Vector4D<T>& b);
00142
00143 template<typename T> Vector4D<T> operator+(const Vector4D<T>& a, typename Vector4D<T>::TParam b);
00144 template<typename T> Vector4D<T> operator-(const Vector4D<T>& a, typename Vector4D<T>::TParam b);
00145 template<typename T> Vector4D<T> operator*(const Vector4D<T>& a, typename Vector4D<T>::TParam b);
00146 template<typename T> Vector4D<T> operator/(const Vector4D<T>& a, typename Vector4D<T>::TParam b);
00147
00148 template<typename T> Vector4D<T> operator+(typename Vector4D<T>::TParam a, const Vector4D<T>& b);
00149 template<typename T> Vector4D<T> operator-(typename Vector4D<T>::TParam a, const Vector4D<T>& b);
00150 template<typename T> Vector4D<T> operator*(typename Vector4D<T>::TParam a, const Vector4D<T>& b);
00151
00152
00153 template<typename T> Vector4D<T> pointwiseMin(const Vector4D<T>& a, const Vector4D<T>& b);
00154 template<typename T> Vector4D<T> pointwiseMax(const Vector4D<T>& a, const Vector4D<T>& b);
00155
00156 template <typename T> Vector4D<T> lerp(const Vector4D<T>& a, const Vector4D<T>& b, typename Vector4D<T>::TParam t);
00157
00158 template<typename T, typename Char, typename Traits>
00159 std::basic_ostream<Char, Traits>& operator<<(std::basic_ostream<Char, Traits>& stream, const Vector4D<T>& b);
00160 template<typename T, typename Char, typename Traits>
00161 std::basic_istream<Char, Traits>& operator>>(std::basic_istream<Char, Traits>& stream, Vector4D<T>& b);
00162
00163 template<typename T> io::XmlOStream& operator<<(io::XmlOStream& stream, const Vector4D<T>& b);
00164
00165
00166 }
00167
00168 }
00169
00170 #include "vector_4d.inl"
00171
00172 #define LASS_PRIM_HAVE_PY_EXPORT_TRAITS_VECTOR_4D
00173 #ifdef LASS_GUARDIAN_OF_INCLUSION_UTIL_PYOBJECT_PLUS_H
00174 # include "pyobject_util.h"
00175 #endif
00176
00177 #endif