30 static const double nullValue_ = 0.0;
48 AVector2() { z_ = std::numeric_limits<T>::max(); }
60 explicit AVector2(
const Vector2<T> &) : z_(0) { }
62 explicit AVector2(
const Vector3<T> &v) : z_(v.z_) { }
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_); }
124 Vector2<T>
operator&(
const Vector2<T> &v)
const { Vector2<T> out(-z_*v.y(),z_*v.x());
return out; }
125 Vector3<T>
operator&(
const Vector3<T> &v)
const { Vector3<T> out(-z_*v.y(),z_*v.x(),0);
return out; }
129 T
operator|(
const Vector3<T> &v)
const {
return z_*v.z(); }
132 Vector3<T>
toVector3()
const {
return Vector3<T>(0,0,z_); }
141 Vector2<T> out(v.y()*av.
z(),-v.x()*av.
z());
148 Vector3<T> out(v.y()*av.
z(),-v.x()*av.
z(),0);
155 AVector2<T> out((v1.x()*v2.y()) - (v1.y()*v2.x()));
176 template <
class T>
class AVector3 :
public Vector3<T> {
178 using Vector3<T>::Vector3;
180 AVector3(
const Vector3<T> &v) : Vector3<T>(v) { }
187 Vector2<T>
toVector2()
const {
return Vector2<T>(this->x(),this->y()); }
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()));
253 template <
class T>
inline Vector2<T>
toVect2(
const AVector3<T> &v) {
return Vector2<T>(v.x(),v.y()); }
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()));
297 AVector3<T> out(ceil(v.x()),ceil(v.y()),ceil(v.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
AVector2< T > operator-(const AVector2< T > &av) const
Binary math operator - require temp (till C++0x)
Definition: avect.h:117
T operator|(const Vector3< T > &v) const
Dot product with a Vector3.
Definition: avect.h:129
AVector2< T > operator+(const AVector2< T > &av) const
Binary math operator - require temp (till C++0x)
Definition: avect.h:116
T operator|(const Vector2< T > &) const
Dot product with a Vector2 returns 0.0.
Definition: avect.h:128
T fsum() const
The Manhatten norm.
Definition: avect.h:93
bool operator>(const AVector2< T > &av) const
comparison operator
Definition: avect.h:107
T & rz()
Returns a reference to the z component, cannot reference access x or y.
Definition: avect.h:81
AVector2(const T &t)
Explicit conversion constructor, the z component is initialized to t.
Definition: avect.h:58
const AVector2< T > & operator-=(const AVector2< T > &v)
in-place math operator
Definition: avect.h:110
const AVector2< T > & operator*=(const AVector2< T > &v)
in-place math operator
Definition: avect.h:111
bool operator==(const AVector2< T > &av) const
comparison operator
Definition: avect.h:104
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
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
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
const AVector2< T > & operator/=(const T &t)
in-place math operator
Definition: avect.h:114
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
PUSHWARNING VSWARNING(26495) AVector2()
Default constructor, no data initialization.
Definition: avect.h:51
bool operator!=(const AVector2< T > &av) const
comparison operator
Definition: avect.h:105
AVector2< T > operator*(const T &t) const
Binary math operator - require temp (till C++0x)
Definition: avect.h:119
const T & x() const
Member access - the x and y values are always uniquely 0 for a 2D angular vector.
Definition: avect.h:66
const T & y() const
Member access - the x and y values are always uniquely 0 for a 2D angular vector.
Definition: avect.h:68
T mag2() const
The square of the magnitude, or the vector dotted with itself.
Definition: avect.h:94
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
void fill(const T &d)
Fill all components with d.
Definition: avect.h:100
Vector3< T > toVector3() const
Converts to a Vector3(0,0,z)
Definition: avect.h:132
Vector3< T > operator&(const Vector3< T > &v) const
Cross product with a Vector3 produces a Vector3 (z=0)
Definition: avect.h:125
Vector2< T > toVector2() const
Converts to a Vector2(0,0)
Definition: avect.h:131
T operator&(const AVector2< T > &) const
Cross product with another AVector2 will always return 0.0.
Definition: avect.h:123
AVector2< T > operator*(const AVector2< T > &av) const
Binary math operator - require temp (till C++0x)
Definition: avect.h:118
const AVector2< T > & operator+=(const AVector2< T > &v)
in-place math operator
Definition: avect.h:109
T & rdof([[maybe_unused]] uint32 u)
Returns a reference to the z component if u=2, any other value of u is an error.
Definition: avect.h:83
T volume() const
Volume represented by x*y*z, always returns 0.0.
Definition: avect.h:97
Vector2< T > operator&(const Vector2< T > &v) const
Cross product with a Vector2 produces a Vector2.
Definition: avect.h:124
const AVector2< T > & operator*=(const T &t)
in-place math operator
Definition: avect.h:112
const T & z() const
Member access - returns the z component of the 2D angular vector.
Definition: avect.h:70
AVector2< T > operator/(const T &t) const
Binary math operator - require temp (till C++0x)
Definition: avect.h:121
T minComp() const
Returns the minimum component (assuming x and y are 0.0)
Definition: avect.h:102
AVector2< T > operator/(const AVector2< T > &av) const
Binary math operator - require temp (till C++0x)
Definition: avect.h:120
T maxComp() const
Returns the maximum component (assuming x and y are 0.0)
Definition: avect.h:101
T area() const
Area represented by x*y, always returns 0.0.
Definition: avect.h:96
AVector2< T > unit() const
returns a unit vector.
Definition: avect.h:98
AVector2< T > abs() const
Returns a vector of absolute values of components.
Definition: avect.h:99
3D Angular vector class.
Definition: avect.h:176
const Vector3< T > & toVector3() const
Converts to a Vector3 directly.
Definition: avect.h:189
AVector3(const AVector2< T > &v)
Explicit conversion contructor from an AVector2, x=0, y=0, z=v.z.
Definition: avect.h:183
Vector2< T > toVector2() const
Converts to a Vector2, the z component is lost.
Definition: avect.h:187
Vector2< T > toVect2(const AVector3< T > &v)
Definition: avect.h:253
AVector2< T > vceil(const AVector2< T > &v)
Definition: avect.h:324
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
constexpr Vector3< T > toVect3(const Vector2< T > &v, const T &t=0)
Conversion between vectors of different dimension.
Definition: vect.h:341
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.