17 Vec3(T value=0) : x(value), y(value), z(value) {}
20 Vec3(T _x, T _y, T _z) : x(_x), y(_y), z(_z) {}
54 return Vec3<T>(T(x*d),T(y*d),T(z*d));
67 return Vec3<T>(T(x/d),T(y/d),T(z/d));
80 return x*v.
x + y*v.
y + z*v.
z;
106 return std::sqrt(
double(x*x+y*y+z*z));
116 return (x==v.
x && y==v.
y && z==v.
z);
121 return !((*this)==v);
130 operator T() {
return x; }
133 friend std::ostream& operator<<(std::ostream &os, const Vec3<T> &v) {
134 os << v.x <<
" " << v.y<<
" "<<v.z;
Vec3(T _x, T _y, T _z)
Constructor accepting three values, one for each vector component.
Definition: Vector3.h:20
Vec3< float > Vec3f
Definition: Vector3.h:148
T z
Definition: Vector3.h:13
Vec3< T > operator/(const double &d) const
Division with double.
Definition: Vector3.h:66
bool operator!=(const Vec3< T > &v) const
Not equal (used for integer position vectors)
Definition: Vector3.h:120
Class representing 3D vectors, with elements of type T.
Definition: Vector3.h:9
Vec3< T > operator%(const Vec3< T > &v) const
Element-wise multiplication (hadamard product)
Definition: Vector3.h:93
Vec3< T > & operator-=(const Vec3< T > &v)
In-place vector subtraction.
Definition: Vector3.h:45
Vec3< T > cross(const Vec3< T > &v) const
Cross product.
Definition: Vector3.h:84
Vec3< int > Vec3i
Definition: Vector3.h:150
T x
Definition: Vector3.h:11
Vec3< T > & operator/=(const double &d)
In-place division with double.
Definition: Vector3.h:71
Vec3< T > operator*(const double &d) const
Multiplication with double.
Definition: Vector3.h:53
friend Vec3< T > operator*(const double &d, const Vec3< T > &v)
Multiplication with double.
Definition: Vector3.h:125
Vec3< T > & operator*=(const double &d)
In-place multiplication with double.
Definition: Vector3.h:58
double operator*(const Vec3< T > &v) const
Scalar product.
Definition: Vector3.h:79
Vec3< T > & operator+=(const Vec3< T > &v)
In-place vector addition.
Definition: Vector3.h:32
double norm() const
Vector norm.
Definition: Vector3.h:105
double norm2() const
Vector norm squared.
Definition: Vector3.h:110
Vec3(Vec3< T2 > v)
Copy constructor.
Definition: Vector3.h:24
Vec3< T > operator+(const Vec3< T > &v) const
Vector addition.
Definition: Vector3.h:27
Vec3< double > Vec3d
Definition: Vector3.h:149
Vec3< T > operator-(const Vec3< T > &v) const
Vector subtraction.
Definition: Vector3.h:40
Vec3(T value=0)
Constructor accepting a single value, which defaults to 0. All three components are set to the same v...
Definition: Vector3.h:17
T y
Definition: Vector3.h:12
bool operator==(const Vec3< T > &v) const
Equal (used for integer position vectors)
Definition: Vector3.h:115
Vec3< T > & normalize()
Normalize.
Definition: Vector3.h:98