14 template <
class T> T abs(
const T &t) {
18 template <
class T> T max0(
const T &t1,
const T &t2) {
22 template <
class T> T min0(
const T &t1,
const T &t2) {
32class Vector2 :
public std::array<T,2> {
34 using Base = std::array<T,2>;
36 static constexpr uint32 vdim = 2;
38 constexpr Vector2() : Base({T{},T{}}) { }
40 constexpr Vector2(
const Vector2<T> &v) =
default;
41 constexpr Vector2<T>& operator=(
const Vector2<T>& in) =
default;
46 explicit constexpr Vector2(
const T &t) : Base({t,t}) { }
53 constexpr const T &
x()
const {
return dof(0); }
55 constexpr const T &
y()
const {
return dof(1); }
56 constexpr const T &z()
const {
return dof(1); }
58 constexpr const T &
dof(
unsigned u)
const { assert(u<vdim);
return Base::operator[](u); }
63 T &rz() {
return rdof(1); }
65 T &
rdof(
unsigned u) { assert(u<vdim);
return Base::operator[](u); }
66 template <std::
size_t N>
constexpr decltype(
auto) get()
const {
67 static_assert(N<2,
"Index out of range");
68 return Base::operator[](N);
70 template <>
constexpr decltype(
auto) get<2>()
const {
return dof(1); }
74 constexpr T
fsum()
const {
return (std::abs(
x())+std::abs(
y())); }
76 constexpr T
sum()
const {
return x() +
y(); }
78 constexpr T
mag2()
const {
return (
x()*
x()+
y()*
y()); }
82 constexpr T
area()
const {
return (
x()*
y()); }
86 constexpr T
spread()
const {
return (
y() -
x()); }
88 constexpr Vector2<T>
unit()
const { Vector2<T> v(*
this); T m(v.
mag());
if (m) v/=m;
return v; }
90 constexpr Vector2<T>
abs()
const { Vector2<T> v(std::abs(
x()),std::abs(
y()));
return v; }
92 constexpr void fill(
const T &d) {
rx()=d;
ry()=d; }
104 constexpr bool operator==(
const Vector2<T> &v)
const {
return ((
x()==v.
x())&&(
y()==v.
y())); }
106 constexpr bool operator!=(
const Vector2<T> &v)
const {
return ((
x()!=v.
x())||(
y()!=v.
y())); }
108 constexpr bool operator<(
const Vector2<T> &v)
const {
if (
x()!=v.
x())
return x()<v.
x();
return y()<v.
y(); }
110 constexpr bool operator>(
const Vector2<T> &v)
const {
if (
x()!=v.
x())
return x()>v.
x();
return y()>v.
y(); }
114 constexpr const Vector2<T> &
operator+=(
const Vector2<T> &v) {
rx()+=v.
x();
ry()+=v.
y();
return *
this; }
115 constexpr const Vector2<T> &
operator-=(
const Vector2<T> &v) {
rx()-=v.
x();
ry()-=v.
y();
return *
this; }
116 constexpr const Vector2<T> &
operator*=(
const Vector2<T> &v) {
rx()*=v.
x();
ry()*=v.
y();
return *
this; }
117 constexpr const Vector2<T> &
operator*=(
const T &t) {
rx()*=t;
ry()*=t;
return *
this; }
118 constexpr const Vector2<T> &
operator/=(
const Vector2<T> &v) {
rx()/=v.
x();
ry()/=v.
y();
return *
this; }
119 constexpr const Vector2<T> &
operator/=(
const T &t) {
rx()/=t;
ry()/=t;
return *
this; }
123 constexpr Vector2<T>
operator+(
const Vector2<T> &v)
const { Vector2<T> out(
x()+v.
x(),
y()+v.
y());
return out; }
124 constexpr Vector2<T>
operator-(
const Vector2<T> &v)
const { Vector2<T> out(
x()-v.
x(),
y()-v.
y());
return out; }
125 constexpr Vector2<T>
operator*(
const Vector2<T> &v)
const { Vector2<T> out(
x()*v.
x(),
y()*v.
y());
return out; }
126 constexpr Vector2<T>
operator*(
const T &t)
const { Vector2<T> out(
x()*t,
y()*t);
return out; }
127 constexpr Vector2<T>
operator/(
const Vector2<T> &v)
const { Vector2<T> out(
x()/v.
x(),
y()/v.
y());
return out; }
128 constexpr Vector2<T>
operator/(
const T &t)
const { Vector2<T> out(
x()/t,
y()/t);
return out; }
131 constexpr T
operator|(
const Vector2<T> &v)
const {
return (
x()*v.
x()+
y()*v.
y()); }
143 constexpr bool contains(
const T &t)
const {
if (t<
x())
return false;
if (t>
y())
return false;
return true; }
150class Vector3 :
public std::array<T,3> {
152 using Base = std::array<T,3>;
154 static constexpr uint32 vdim = 3;
156 constexpr Vector3() : Base({T{},T{},T{}}) {}
157 constexpr Vector3(
const Vector3<T> &v)=
default;
158 constexpr Vector3<T>& operator=(
const Vector3<T>& in)=
default;
163 explicit constexpr Vector3(
const T &t) : Base({t,t,t}) { }
167 constexpr const T &
x()
const {
return dof(0); }
169 constexpr const T &
y()
const {
return dof(1); }
171 constexpr const T &
z()
const {
return dof(2); }
173 constexpr const T &
dof(
unsigned u)
const { assert(u<vdim);
return Base::operator[](u); }
181 T &
rdof(
unsigned u) { assert(u<vdim);
return Base::operator[](u); }
182 template <std::
size_t N>
constexpr T get()
const {
183 static_assert(N<3,
"Index out of range");
184 return Base::operator[](N);
189 constexpr T
fsum()
const {
return (std::abs(
x())+std::abs(
y())+std::abs(
z())); }
191 constexpr T
sum()
const {
return x()+
y()+
z(); }
193 constexpr T
mag2()
const {
return (
x()*
x()+
y()*
y()+
z()*
z()); }
199 Vector3<T>
unit()
const { Vector3<T> v(*
this); T m(v.
mag()); v /= m;
return v; }
201 constexpr Vector3<T>
abs()
const { Vector3<T> v(std::abs(
x()),std::abs(
y()),std::abs(
z()));
return v; }
209 constexpr unsigned maxCompIndex()
const {
return x() >
y() ? (
x() >
z() ? 0 : 2) : (
y() >
z() ? 1 : 2); }
211 constexpr unsigned minCompIndex()
const {
return x() <
y() ? (
x() <
z() ? 0 : 2) : (
y() <
z() ? 1 : 2); }
214 constexpr bool operator==(
const Vector3<T> &v)
const {
return ((
x()==v.
x())&&(
y()==v.
y())&&(
z()==v.
z())); }
216 constexpr bool operator!=(
const Vector3<T> &v)
const {
return ((
x()!=v.
x())||(
y()!=v.
y())||(
z()!=v.
z())); }
218 constexpr bool operator<(
const Vector3<T> &v)
const {
if (
x()!=v.
x())
return x()<v.
x();
if (
y()!=v.
y())
return y()<v.
y();
return z()<v.
z(); }
220 constexpr bool operator>(
const Vector3<T> &v)
const {
if (
x()!=v.
x())
return x()>v.
x();
if (
y()!=v.
y())
return y()>v.
y();
return z()>v.
z(); }
224 constexpr const Vector3<T> &
operator+=(
const Vector3<T> &v) {
rx()+=v.
x();
ry()+=v.
y();
rz()+=v.
z();
return *
this; }
225 constexpr const Vector3<T> &
operator-=(
const Vector3<T> &v) {
rx()-=v.
x();
ry()-=v.
y();
rz()-=v.
z();
return *
this; }
226 constexpr const Vector3<T> &
operator*=(
const Vector3<T> &v) {
rx()*=v.
x();
ry()*=v.
y();
rz()*=v.
z();
return *
this; }
227 constexpr const Vector3<T> &
operator*=(
const T &t) {
rx()*=t;
ry()*=t;
rz()*=t;
return *
this; }
228 constexpr const Vector3<T> &
operator/=(
const Vector3<T> &v) {
rx()/=v.
x();
ry()/=v.
y();
rz()/=v.
z();
return *
this; }
229 constexpr const Vector3<T> &
operator/=(
const T &t) {
rx()/=t;
ry()/=t;
rz()/=t;
return *
this; }
233 constexpr Vector3<T>
operator+(
const Vector3<T> &v)
const { Vector3<T> out(
x()+v.
x(),
y()+v.
y(),
z()+v.
z());
return out; }
234 constexpr Vector3<T>
operator-(
const Vector3<T> &v)
const { Vector3<T> out(
x()-v.
x(),
y()-v.
y(),
z()-v.
z());
return out; }
235 constexpr Vector3<T>
operator*(
const Vector3<T> &v)
const { Vector3<T> out(
x()*v.
x(),
y()*v.
y(),
z()*v.
z());
return out; }
236 constexpr Vector3<T>
operator*(
const T &t)
const { Vector3<T> out(
x()*t,
y()*t,
z()*t);
return out; }
237 constexpr Vector3<T>
operator/(
const Vector3<T> &v)
const { Vector3<T> out(
x()/v.
x(),
y()/v.
y(),
z()/v.
z());
return out; }
238 constexpr Vector3<T>
operator/(
const T &t)
const { Vector3<T> out(
x()/t,
y()/t,
z()/t);
return out; }
240 constexpr Vector3<T>
operator&(
const Vector3<T> &v)
const {
241 Vector3<T> out((
y()*v.
z())-(
z()*v.
y()),(
z()*v.
x())-(
x()*v.
z()),(
x()*v.
y())-(
y()*v.
x()));
245 constexpr T
operator|(
const Vector3<T> &v)
const {
return (
x()*v.
x()+
y()*v.
y()+
z()*v.
z()); }
281template <
class T>
inline constexpr DVect3
toDVect3(
const Vector3<T> &v) {
287template <
class T>
inline constexpr FVect3
toFVect3(
const Vector3<T> &v) {
293template <
class T>
inline constexpr IVect3
toIVect3(
const Vector3<T> &v) {
297template <
class T>
inline I64Vect3 toI64Vect3(
const Vector3<T> &v) {
303template <
class T>
inline constexpr U64Vect3
toU64Vect3(
const Vector3<T> &v) {
318template <
class T>
inline constexpr Vector2<T>
vmax(
const Vector2<T> &v1,
const Vector2<T> &v2) {
324template <
class T>
inline constexpr Vector2<T>
vmin(
const Vector2<T> &v1,
const Vector2<T> &v2) {
331template <
class T>
inline constexpr Vector2<T>
vsign(
const Vector2<T> &v1,
const Vector2<T> &v2) {
332 Vector2<T> out(v2.
x() < 0 ? -qAbs(v1.
x()) : qAbs(v1.
x()) ,v2.
y() < 0 ? -qAbs(v1.
y()) : qAbs(v1.
y()));
338template <
class T>
inline constexpr Vector3<T>
vmax(
const Vector3<T> &v1,
const Vector3<T> &v2) {
344template <
class T>
inline constexpr Vector3<T>
vmin(
const Vector3<T> &v1,
const Vector3<T> &v2) {
351template <
class T>
inline constexpr Vector3<T>
vsign(
const Vector3<T> &v1,
const Vector3<T> &v2) {
352 Vector3<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()));
358template <
class T>
inline Vector2<T>
vceil(
const Vector2<T> &v) {
359 Vector2<T> out(ceil(v.
x()),ceil(v.
y()));
365template <
class T>
inline Vector3<T>
vceil(
const Vector3<T> &v) {
366 Vector3<T> out(ceil(v.
x()),ceil(v.
y()),ceil(v.
z()));
372template <
class T>
inline Vector2<T>
vfloor(
const Vector2<T> &v) {
373 Vector2<T> out(floor(v.
x()),floor(v.
y()));
379template <
class T>
inline Vector3<T>
vfloor(
const Vector3<T> &v) {
380 Vector3<T> out(floor(v.
x()),floor(v.
y()),floor(v.
z()));
386template <
class T> IVect2
vround(
const Vector2<T> &v) {
387 IVect2 out(qRound(v.
x()),qRound(v.
y()));
393template <
class T> IVect3
constexpr vround(
const Vector3<T> &v) {
394 IVect3 out(qRound(v.
x()),qRound(v.
y()),qRound(v.
z()));
397template <
class T> I64Vect3
constexpr v64round(
const Vector3<T> &v) {
398 I64Vect3 out(std::llround(v.
x()),std::llround(v.
y()),std::llround(v.
z()));
413 template <
class T>
struct tuple_size<
Vector2<T>> : std::integral_constant<std::size_t, 2> {};
414 template <
class T>
struct tuple_size<
Vector3<T>> : std::integral_constant<std::size_t, 3> {};
415 template <std::
size_t N,
class T>
struct tuple_element<N,
Vector2<T>> {
using type = T; };
416 template <std::
size_t N,
class T>
struct tuple_element<N,
Vector3<T>> {
using type = T; };
422 namespace basehelper {
423 template <
typename T>
424 string tsVect(
const Vector2<T> &t,
int width,
char notation,
int precision,
char fill) {
425 if (abs(width) > 5) width = width < 0 ? -abs(abs(width) - 3) : abs(abs(width) - 3);
427 int w2 = std::abs(width)/2;
428 int w1 = std::abs(width) - w2;
429 if (width<0) { w1 *= -1; w2 *= -1; }
430 return "("+ts(t.
x(), w1, notation, precision, fill)+
","
431 +ts(t.
y(), w2, notation, precision, fill)+
")";
433 template <
typename T>
434 string tsVect(
const Vector3<T> &t,
int width,
char notation,
int precision,
char fill) {
435 if (abs(width) > 7) width = width < 0 ? -abs(abs(width) - 4) : abs(abs(width) - 4);
437 int w3 = std::abs(width)/3;
438 int w2 = (std::abs(width)-w3)/2;
439 int w1 = std::abs(width) - w2 - w3;
440 if (width<0) { w1 *= -1; w2 *= -1; w3 *= -1; }
441 return "("+ts(t.
x(), w1, notation, precision, fill)+
","
442 +ts(t.
y(), w2, notation, precision, fill)+
","
443 +ts(t.
z(), w3, notation, precision, fill)+
")";
448 inline string ts(
const DVect2 &t,
int width,
char notation,
int precision,
char fill) {
449 return basehelper::tsVect(t, width, notation, precision, fill);
453 inline string ts(
const DVect3 &t,
int width,
char notation,
int precision,
char fill) {
454 return basehelper::tsVect(t, width, notation, precision, fill);
458 inline string ts(
const IVect2 &t,
int width,
char notation,
int precision,
char fill) {
459 return basehelper::tsVect(t, width, notation, precision, fill);
463 inline string ts(
const IVect3 &t,
int width,
char notation,
int precision,
char fill) {
464 return basehelper::tsVect(t, width, notation, precision, fill);
468 inline string ts(
const I64Vect2 &t,
int width,
char notation,
int precision,
char fill) {
469 return basehelper::tsVect(t, width, notation, precision, fill);
473 inline string ts(
const I64Vect3 &t,
int width,
char notation,
int precision,
char fill) {
474 return basehelper::tsVect(t, width, notation, precision, fill);
482struct std::formatter<
Vector2<T>> :
public std::formatter<double> {
483 template <
typename ParseContext>
484 constexpr auto parse(ParseContext &ctx) {
return std::formatter<double>::parse(ctx); }
487 template <
typename FormatContext>
488 constexpr auto format(
Vector2<T> const &val, FormatContext &ctx)
const {
489 format_to(ctx.out(),
"(");
490 std::formatter<double>::format(val.
x(),ctx);
491 format_to(ctx.out(),
",");
492 std::formatter<double>::format(val.
y(),ctx);
493 return format_to(ctx.out(),
")");
501struct std::formatter<
Vector3<T>> :
public std::formatter<double> {
502 template <
typename ParseContext>
503 constexpr auto parse(ParseContext &ctx) {
return std::formatter<double>::parse(ctx); }
506 template <
typename FormatContext>
507 constexpr auto format(
Vector3<T> const &val, FormatContext &ctx)
const {
508 format_to(ctx.out(),
"(");
509 std::formatter<double>::format(val.
x(),ctx);
510 format_to(ctx.out(),
",");
511 std::formatter<double>::format(val.
y(),ctx);
512 format_to(ctx.out(),
",");
513 std::formatter<double>::format(val.
z(),ctx);
514 return format_to(ctx.out(),
")");
520 return safeSquare(v.
x()) + safeSquare(v.
y());
531 Vector2<T> ret(::safeDiv(a.
x(),b.
x(),safe.x()),::safeDiv(a.
y(),b.
y(),safe.y()));
537 Vector2<T> ret(::safeDiv(a.
x(),v,safe.x()),::safeDiv(a.
y(),v,safe.y()));
549 return std::isfinite(a.
x()) and std::isfinite(a.y());
553constexpr T safeMag2(const
Vector3<T> &v) {
554 return safeSquare(v.x()) + safeSquare(v.y()) + safeSquare(v.z());
565 Vector3<T> ret(::safeDiv(a.
x(),b.
x(),safe.x()),::safeDiv(a.
y(),b.
y(),safe.y()),::safeDiv(a.
z(),b.
z(),safe.z()));
571 Vector3<T> ret(::safeDiv(a.
x(),v,safe.x()),::safeDiv(a.
y(),v,safe.y()),::safeDiv(a.
z(),v,safe.z()));
583 return std::isfinite(a.
x()) and std::isfinite(a.y()) and std::isfinite(a.z());
includes std::string and additional functions not included in the standard.
2D vector utility class.
Definition vect.h:32
constexpr Vector2< T > operator*(const Vector2< T > &v) const
Binary mathematical operators using vectors and scalars – Note that * and / of Vector2 types are done...
Definition vect.h:125
constexpr T minComp() const
Returns the minimum component.
Definition vect.h:96
constexpr bool operator>(const Vector2< T > &v) const
Comparison operator, based on magnitude.
Definition vect.h:110
constexpr const Vector2< T > & operator/=(const Vector2< T > &v)
In place mathematical operators using vectors and scalars – Note that * and / of Vector2 types are do...
Definition vect.h:118
constexpr Vector2< T > unit() const
Unit vector - be sure vector is nonzero.
Definition vect.h:88
constexpr void fill(const T &d)
Fills all three components with value d.
Definition vect.h:92
constexpr T mag2() const
Square of the magnitude, or the dot product with itself.
Definition vect.h:78
constexpr Vector2(const Vector2< T > &v)=default
Copy constructor.
constexpr Vector2< T > expandedToInclude(const T &t) const
Returns 1D range expanded to include value t;.
Definition vect.h:139
constexpr const Vector2< T > & expandToInclude(const Vector2< T > &v)
Expands 1D range to include 1D range v.
Definition vect.h:137
constexpr const Vector2< T > & operator/=(const T &t)
In place mathematical operators using vectors and scalars – Note that * and / of Vector2 types are do...
Definition vect.h:119
constexpr const Vector2< T > & expandToInclude(const T &t)
Expands 1D range to include value t.
Definition vect.h:135
constexpr unsigned maxCompIndex() const
Returns the max component index.
Definition vect.h:98
constexpr const Vector2< T > & operator+=(const Vector2< T > &v)
In place mathematical operators using vectors and scalars – Note that * and / of Vector2 types are do...
Definition vect.h:114
constexpr T spread() const
Assumes vector is being used to store a 1D extent– Returns max-min. (y-x).
Definition vect.h:86
constexpr const Vector2< T > & operator-=(const Vector2< T > &v)
In place mathematical operators using vectors and scalars – Note that * and / of Vector2 types are do...
Definition vect.h:115
constexpr bool operator==(const Vector2< T > &v) const
"Safe" division operation - checks for zero and overflow.
Definition vect.h:104
constexpr T operator|(const Vector2< T > &v) const
Dot Product.
Definition vect.h:131
constexpr const Vector2< T > & operator*=(const Vector2< T > &v)
In place mathematical operators using vectors and scalars – Note that * and / of Vector2 types are do...
Definition vect.h:116
constexpr Vector2< T > operator-(const Vector2< T > &v) const
Binary mathematical operators using vectors and scalars – Note that * and / of Vector2 types are done...
Definition vect.h:124
constexpr const double & x() const
Definition vect.h:53
constexpr T volume() const
Volume of the rectangle assuming unit depth – same as area(), provided for 2D/3D compile compatibilit...
Definition vect.h:84
constexpr Vector2< T > expandedToInclude(const Vector2< T > &v) const
Returns 1D range expanded to include 1D range v.
Definition vect.h:141
constexpr T mag() const
The magnitude.
Definition vect.h:80
constexpr const T & dof(unsigned u) const
Access to degree of freedom u (0-1).
Definition vect.h:58
T & rdof(unsigned u)
Reference accesss to degree-of-freedom u (0-1).
Definition vect.h:65
constexpr T maxComp() const
Returns the maximum component.
Definition vect.h:94
constexpr bool operator<(const Vector2< T > &v) const
Comparison operator, based on magnitude.
Definition vect.h:108
constexpr bool contains(const T &t) const
True if value t falls inside this 1D range (inclusive).
Definition vect.h:143
constexpr T fsum() const
Manhattan norm.
Definition vect.h:74
constexpr const Vector2< T > & operator*=(const T &t)
In place mathematical operators using vectors and scalars – Note that * and / of Vector2 types are do...
Definition vect.h:117
constexpr Vector2< T > abs() const
Returns vector of absolute values of components.
Definition vect.h:90
constexpr Vector2< T > operator/(const T &t) const
Binary mathematical operators using vectors and scalars – Note that * and / of Vector2 types are done...
Definition vect.h:128
constexpr Vector2< T > operator*(const T &t) const
Binary mathematical operators using vectors and scalars – Note that * and / of Vector2 types are done...
Definition vect.h:126
static Vector2< T > nothing()
Creates an "empty" vector, useful when Vector2 is used as a 1D extent.
Definition vect.h:49
constexpr bool operator!=(const Vector2< T > &v) const
Comparison operator - no tolerance is used.
Definition vect.h:106
constexpr Vector2< T > operator/(const Vector2< T > &v) const
Binary mathematical operators using vectors and scalars – Note that * and / of Vector2 types are done...
Definition vect.h:127
constexpr T area() const
Size of rectangle represented by x*y - can be negative.
Definition vect.h:82
constexpr unsigned minCompIndex() const
Returns the min component index.
Definition vect.h:100
T & rx()
Reference access to x-component.
Definition vect.h:60
constexpr T sum() const
Sum of components.
Definition vect.h:76
constexpr Vector2(const T &t)
Explicit contructor, each component is given value t.
Definition vect.h:46
constexpr const double & y() const
Definition vect.h:55
constexpr Vector2< T > operator+(const Vector2< T > &v) const
Binary mathematical operators using vectors and scalars – Note that * and / of Vector2 types are done...
Definition vect.h:123
constexpr Vector2(const T &x, const T &y)
Explicit constructor, from two components.
Definition vect.h:44
T & ry()
Reference access to y-component.
Definition vect.h:62
3D vector utility class.
Definition vect.h:150
constexpr bool operator<(const Vector3< T > &v) const
Comparison operator, compare each DOF in order.
Definition vect.h:218
constexpr const double & y() const
Definition vect.h:169
T & rx()
Reference access to the x-component of the vector.
Definition vect.h:175
constexpr T maxComp() const
Returns the maximum component.
Definition vect.h:205
constexpr Vector3< T > operator&(const Vector3< T > &v) const
Cross Product.
Definition vect.h:240
constexpr T operator|(const Vector3< T > &v) const
Dot Product.
Definition vect.h:245
T & ry()
Reference access to the y-component of the vector.
Definition vect.h:177
constexpr const Vector3< T > & operator-=(const Vector3< T > &v)
In-place mathematical operators – * and / are done on a component basis.
Definition vect.h:225
constexpr const Vector3< T > & operator+=(const Vector3< T > &v)
In-place mathematical operators – * and / are done on a component basis.
Definition vect.h:224
constexpr unsigned minCompIndex() const
Returns the min component index.
Definition vect.h:211
constexpr Vector3< T > operator+(const Vector3< T > &v) const
Binary mathematical operators – * and / are done on a component basis.
Definition vect.h:233
constexpr bool operator>(const Vector3< T > &v) const
Comparison operator, compare each DOF in order.
Definition vect.h:220
constexpr const Vector3< T > & operator*=(const Vector3< T > &v)
In-place mathematical operators – * and / are done on a component basis.
Definition vect.h:226
constexpr T fsum() const
Manhattan norm.
Definition vect.h:189
constexpr Vector3< T > operator/(const T &t) const
Binary mathematical operators – * and / are done on a component basis.
Definition vect.h:238
constexpr T minComp() const
Returns the minimum component.
Definition vect.h:207
constexpr const Vector3< T > & operator/=(const Vector3< T > &v)
In-place mathematical operators – * and / are done on a component basis.
Definition vect.h:228
constexpr const Vector3< T > & operator/=(const T &t)
In-place mathematical operators – * and / are done on a component basis.
Definition vect.h:229
constexpr Vector3< T > operator*(const Vector3< T > &v) const
Binary mathematical operators – * and / are done on a component basis.
Definition vect.h:235
constexpr const double & x() const
Definition vect.h:167
constexpr T mag2() const
Square of the magnitude, or the vector dotted with itself.
Definition vect.h:193
constexpr bool operator!=(const Vector3< T > &v) const
Comparison operator - no tolerance is used.
Definition vect.h:216
constexpr Vector3< T > operator/(const Vector3< T > &v) const
Binary mathematical operators – * and / are done on a component basis.
Definition vect.h:237
constexpr const Vector3< T > & operator*=(const T &t)
In-place mathematical operators – * and / are done on a component basis.
Definition vect.h:227
T & rdof(unsigned u)
Reference access to degree-of-freedom u (0-2) of the vector.
Definition vect.h:181
constexpr Vector3(const T &t)
Explicit constructor, all three components are inintialized to t.
Definition vect.h:163
constexpr bool operator==(const Vector3< T > &v) const
Comparison operator - no tolerance is used.
Definition vect.h:214
constexpr T volume() const
Volume of region represented by x*y*z - can be negative.
Definition vect.h:197
void fill(const T &d)
Fills all three components with value d.
Definition vect.h:203
Vector3< T > unit() const
Unit vector - be sure vector is nonzero.
Definition vect.h:199
constexpr unsigned maxCompIndex() const
Returns the max component index.
Definition vect.h:209
constexpr Vector3< T > abs() const
Returns vector of absolute values of components.
Definition vect.h:201
constexpr const double & z() const
Definition vect.h:171
constexpr Vector3< T > operator*(const T &t) const
Binary mathematical operators – * and / are done on a component basis.
Definition vect.h:236
constexpr T mag() const
The vector magnitude.
Definition vect.h:195
T & rz()
Reference access to the z-component of the vector.
Definition vect.h:179
constexpr Vector3(const T &x, const T &y, const T &z=0)
Explicit constructor, by the three components of the vector.
Definition vect.h:161
constexpr T sum() const
Sum of components.
Definition vect.h:191
constexpr const T & dof(unsigned u) const
The degree-of-freedom u (0-2) component.
Definition vect.h:173
constexpr Vector3< T > operator-(const Vector3< T > &v) const
Binary mathematical operators – * and / are done on a component basis.
Definition vect.h:234
debug checked shorthand for std::numeric_limits<T>::
Definition limit.h:25
Vector3< T > vceil(const Vector3< T > &v)
Definition vect.h:365
constexpr Vector3< T > toVect3(const Vector2< T > &v, const T &t=0)
Conversion between vectors of different dimension.
Definition vect.h:312
constexpr const Vector2< T > safeDiv(const Vector2< T > &a, const Vector2< T > &b, const Vector2< T > &safe=Vector2< T >(0))
"Safe" division operation - checks for zero and overflow.
Definition vect.h:530
constexpr U64Vect3 toU64Vect3(const Vector3< T > &v)
Definition vect.h:303
IVect2 vround(const Vector2< T > &v)
Definition vect.h:386
constexpr Vector2< T > vmax(const Vector2< T > &v1, const Vector2< T > &v2)
Definition vect.h:318
constexpr FVect3 toFVect3(const Vector3< T > &v)
Definition vect.h:287
constexpr Vector3< T > vmax(const Vector3< T > &v1, const Vector3< T > &v2)
Definition vect.h:338
IVect3 constexpr vround(const Vector3< T > &v)
Definition vect.h:393
Vector2< T > vfloor(const Vector2< T > &v)
Definition vect.h:372
constexpr IVect2 toIVect2(const Vector2< T > &v)
Definition vect.h:272
Vector3< T > vfloor(const Vector3< T > &v)
Definition vect.h:379
constexpr const Vector2< T > & toVect2(const Vector2< T > &v)
Conversion between vectors of different dimension.
Definition vect.h:310
Vector2< T > vceil(const Vector2< T > &v)
Definition vect.h:358
constexpr Vector3< T > vmin(const Vector3< T > &v1, const Vector3< T > &v2)
Definition vect.h:344
constexpr DVect3 toDVect3(const Vector3< T > &v)
Definition vect.h:281
constexpr IVect3 toIVect3(const Vector3< T > &v)
Definition vect.h:293
constexpr D to(const T &t)
This template function serves as an alternative to static_cast<T>().
Definition to.h:28
constexpr UVect2 toUVect2(const Vector2< T > &v)
Definition vect.h:276
constexpr Vector3< T > vsign(const Vector3< T > &v1, const Vector3< T > &v2)
Definition vect.h:351
constexpr DVect2 toDVect2(const Vector2< T > &v)
Definition vect.h:266
constexpr Vector2< T > vsign(const Vector2< T > &v1, const Vector2< T > &v2)
Definition vect.h:331
constexpr FVect2 toFVect2(const Vector2< T > &v)
Definition vect.h:269
constexpr Vector2< T > vmin(const Vector2< T > &v1, const Vector2< T > &v2)
Definition vect.h:324
A overflow checked shorthand for static_cast<T>().
constexpr Vector2< T > max(const Vector2< T > &v1, const Vector2< T > &v2)
Template specialization for max, min.
Definition vect.h:404
constexpr Vector2< T > min(const Vector2< T > &v1, const Vector2< T > &v2)
Template specialization for max, min.
Definition vect.h:406