30 static const double nullValue_ = 0.0;
48 AVector2() { z_ = std::numeric_limits<T>::max(); }
66 const T &
x()
const {
return AVector2Util::nullValue_; }
68 const T &
y()
const {
return AVector2Util::nullValue_; }
70 const T &
z()
const {
return z_; }
72 const T &
dof(uint32 u)
const {
74 if (u>2)
throw std::runtime_error(
"Vector index out of range.");
77 return AVector2Util::nullValue_;
81 T &
rz() {
return z_; }
83 T &
rdof([[maybe_unused]] uint32 u) {
85 if (u!=2)
throw std::runtime_error(
"Vector index out of range.");
93 T
fsum()
const {
return std::abs(z_); }
94 T
mag2()
const {
return z_*z_; }
95 T
mag()
const {
return std::abs(z_); }
96 T
area()
const {
return 0; }
98 AVector2<T> unit()
const {
AVector2<T> v(*
this);
if (z_) { v.z_ = z_ < static_cast<T>(0) ?
static_cast<T
>(-1) :
static_cast<T
>(1); }
return v; }
100 void fill(
const T &d) { z_=d; }
101 T
maxComp()
const {
return std::max(0.0,z_); }
102 T
minComp()
const {
return std::min(0.0,z_); }
220 DAVect3 dv3(to<double>(v.
x()),to<double>(v.
y()),to<double>(v.
z()));
227 FAVect3 fv3(to<float>(v.
x()),to<float>(v.
y()),to<float>(v.
z()));
234 IAVect3 iv3(to<int32>(v.
x()),to<int32>(v.
y()),to<int32>(v.
z()));
241 UAVect3 uv3(to<uint32>(v.
x()),to<uint32>(v.
y()),to<uint32>(v.
z()));
276 AVector3<T> out(std::max<T>(v1.
x(),v2.
x()),std::max<T>(v1.
y(),v2.
y()),std::max<T>(v1.
z(),v2.
z()));
283 AVector3<T> out(std::min<T>(v1.
x(),v2.
x()),std::min<T>(v1.
y(),v2.
y()),std::min<T>(v1.
z(),v2.
z()));
290 AVector3<T> out(v2.
x() < 0 ? -qAbs(v1.
x()) : qAbs(v1.
x()), v2.
y() < 0 ? -qAbs(v1.
y()) : qAbs(v1.
y()), v2.
z() < 0 ? -qAbs(v1.
z()) : qAbs(v1.
z()));
331 inline string ts(
const AVector2<T> &t,
int width=0,
char notation =
'\0',
int precision = -1,
char fill =
' ') {
332 return ts(t.
z(), width, notation, precision, fill);
336 inline string ts(
const AVector3<T> &t,
int width=0,
char notation =
'\0',
int precision = -1,
char fill =
' ') {
337 return ts(
toVect3(t), width, notation, precision, fill);
2D Angular vector class.
Definition avect.h:43
Vector2< T > operator&(const Vector2< T > &v) const
Cross product with a Vector2 produces a Vector2.
Definition avect.h:124
T operator|(const Vector3< T > &v) const
Dot product with a Vector3.
Definition avect.h:129
T operator|(const Vector2< T > &) const
Dot product with a Vector2 returns 0.0.
Definition avect.h:128
T & operator[](uint32 u)
Returns a reference to the z component if u=2, any other value of u is an error.
Definition avect.h:91
T fsum() const
The Manhatten norm.
Definition avect.h:93
AVector2< T > operator-(const AVector2< T > &av) const
Binary math operator - require temp (till C++0x)
Definition avect.h:117
bool operator>(const AVector2< T > &av) const
comparison operator
Definition avect.h:107
AVector2(const T &t)
Explicit conversion constructor, the z component is initialized to t.
Definition avect.h:58
const T & y() const
Member access - the x and y values are always uniquely 0 for a 2D angular vector.
Definition avect.h:68
const AVector2< T > & operator*=(const T &t)
in-place math operator
Definition avect.h:112
bool operator==(const AVector2< T > &av) const
comparison operator
Definition avect.h:104
const T & x() const
Member access - the x and y values are always uniquely 0 for a 2D angular vector.
Definition avect.h:66
bool operator<(const AVector2< T > &av) const
comparison operator
Definition avect.h:106
AVector2(const Vector2< T > &)
Explicit conversion constructor, the z component is set to 0, the x and y values of v are lost.
Definition avect.h:60
T operator|(const AVector2< T > &v) const
Dot product.
Definition avect.h:127
T mag() const
The magnitude of the vector.
Definition avect.h:95
const AVector2< T > & operator-=(const AVector2< T > &v)
in-place math operator
Definition avect.h:110
T & rdof(uint32 u)
Returns a reference to the z component if u=2, any other value of u is an error.
Definition avect.h:83
const AVector2< T > & operator/=(const AVector2< T > &v)
in-place math operator
Definition avect.h:113
AVector2(const Vector3< T > &v)
Explicit convertion contructor, the z component or v is copied but he x and y values are lost.
Definition avect.h:62
POPWARNING AVector2(const AVector2 &av)
Copy constructor.
Definition avect.h:56
bool operator!=(const AVector2< T > &av) const
comparison operator
Definition avect.h:105
const AVector2< T > & operator*=(const AVector2< T > &v)
in-place math operator
Definition avect.h:111
const AVector2< T > & operator/=(const T &t)
in-place math operator
Definition avect.h:114
T mag2() const
The square of the magnitude, or the vector dotted with itself.
Definition avect.h:94
PUSHWARNING AVector2()
Default constructor, no data initialization.
Definition avect.h:52
const AVector2< T > & operator+=(const AVector2< T > &v)
in-place math operator
Definition avect.h:109
void fill(const T &d)
Fill all components with d.
Definition avect.h:100
T & rz()
Returns a reference to the z component, cannot reference access x or y.
Definition avect.h:81
AVector2< T > unit() const
returns a unit vector.
Definition avect.h:98
AVector2< T > operator+(const AVector2< T > &av) const
Binary math operator - require temp (till C++0x)
Definition avect.h:116
AVector2< T > operator*(const T &t) const
Binary math operator - require temp (till C++0x)
Definition avect.h:119
const T & z() const
Member access - returns the z component of the 2D angular vector.
Definition avect.h:70
T operator&(const AVector2< T > &) const
Cross product with another AVector2 will always return 0.0.
Definition avect.h:123
T volume() const
Volume represented by x*y*z, always returns 0.0.
Definition avect.h:97
AVector2< T > operator/(const T &t) const
Binary math operator - require temp (till C++0x)
Definition avect.h:121
const T & operator[](uint32 u) const
General degree-of-freedom access. If u is 2 returns the z component, otherwise returns 0....
Definition avect.h:90
T minComp() const
Returns the minimum component (assuming x and y are 0.0)
Definition avect.h:102
AVector2< T > abs() const
Returns a vector of absolute values of components.
Definition avect.h:99
T maxComp() const
Returns the maximum component (assuming x and y are 0.0)
Definition avect.h:101
Vector3< T > operator&(const Vector3< T > &v) const
Cross product with a Vector3 produces a Vector3 (z=0)
Definition avect.h:125
AVector2< T > operator/(const AVector2< T > &av) const
Binary math operator - require temp (till C++0x)
Definition avect.h:120
T area() const
Area represented by x*y, always returns 0.0.
Definition avect.h:96
const T & dof(uint32 u) const
General degree-of-freedom access. If u is 2 returns the z component, otherwise returns 0....
Definition avect.h:72
AVector2< T > operator*(const AVector2< T > &av) const
Binary math operator - require temp (till C++0x)
Definition avect.h:118
Vector2< T > toVector2() const
Converts to a Vector2(0,0)
Definition avect.h:131
Vector3< T > toVector3() const
Converts to a Vector3(0,0,z)
Definition avect.h:132
3D Angular vector class.
Definition avect.h:176
const Vector3< T > & toVector3() const
Converts to a Vector3 directly.
Definition avect.h:189
Vector2< T > toVector2() const
Converts to a Vector2, the z component is lost.
Definition avect.h:187
AVector3(const AVector2< T > &v)
Explicit conversion contructor from an AVector2, x=0, y=0, z=v.z.
Definition avect.h:183
2D vector utility class.
Definition vect.h:34
constexpr const T & x() const
X component access.
Definition vect.h:58
constexpr const T & y() const
Y component access.
Definition vect.h:60
3D vector utility class.
Definition vect.h:163
constexpr const T & y() const
The y-component of the vector.
Definition vect.h:186
Vector3()
Default constructor - no data initialization.
Definition vect.h:172
constexpr const T & x() const
The x-component of the vector.
Definition vect.h:184
constexpr const T & z() const
The z-component of the vector.
Definition vect.h:188
Vector2< T > toVect2(const AVector3< T > &v)
Definition avect.h:253
AVector2< T > vceil(const AVector2< T > &v)
Definition avect.h:324
constexpr Vector3< T > toVect3(const Vector2< T > &v, const T &t=0)
Conversion between vectors of different dimension.
Definition vect.h:341
IAVect2 toIAVect2(const AVector2< T > &v)
Definition avect.h:212
DAVect3 toDAVect3(const Vector3< T > &v)
Definition avect.h:219
AVector3< T > vsign(const AVector3< T > &v1, const AVector3< T > &v2)
Definition avect.h:289
const AVector2< T > & toAVect2(const AVector2< T > &v)
Definition avect.h:260
UAVect2 toUAVect2(const AVector2< T > &v)
Definition avect.h:215
AVector2< T > vsign(const AVector2< T > &v1, const AVector2< T > &v2)
Definition avect.h:317
UAVect3 toAUVect3(const Vector3< T > &v)
Definition avect.h:240
FAVect2 toFAVect2(const AVector2< T > &v)
Definition avect.h:209
Vector3< T > operator&(const Vector3< T > &v, const AVector2< T > &av)
Definition avect.h:147
AVector3< T > vceil(const AVector3< T > &v)
Definition avect.h:296
AVector3< T > toAVect3(const AVector2< T > &v, const T &x=0, const T &y=0)
Definition avect.h:268
Vector2< T > operator&(const Vector2< T > &v, const AVector2< T > &av)
Definition avect.h:140
AVector2< T > vmin(const AVector2< T > &v1, const AVector2< T > &v2)
Definition avect.h:310
DAVect2 toDAVect2(const AVector2< T > &v)
Definition avect.h:206
FAVect3 toFAVect3(const Vector3< T > &v)
Definition avect.h:226
AVector2< T > toAVect2(const AVector3< T > &v)
Definition avect.h:264
Vector2< T > toVect2(const AVector2< T > &)
Definition avect.h:247
AVector2< T > vmax(const AVector2< T > &v1, const AVector2< T > &v2)
Definition avect.h:303
AVector3< T > vmax(const AVector3< T > &v1, const AVector3< T > &v2)
Definition avect.h:275
Vector3< T > toVect3(const AVector2< T > &v)
Definition avect.h:250
const Vector3< T > & toVect3(const AVector3< T > &v)
Definition avect.h:256
IAVect3 toAIVect3(const Vector3< T > &v)
Definition avect.h:233
AVector3< T > vmin(const AVector3< T > &v1, const AVector3< T > &v2)
Definition avect.h:282
const AVector3< T > & toAVect3(const AVector3< T > &v)
Definition avect.h:271
T operator|(const Vector2< T > &, const AVector2< T > &)
Definition avect.h:161
AVector2< T > operator&(const Vector2< T > &v1, const Vector2< T > &v2)
Definition avect.h:154
2D Angular vector class.
Definition avect.h:29
2D and 3D vector utility classes.