Go to the documentation of this file.
21 template <
typename T>
struct Vec3
33 Vec3(
const T &xyz) :
x(xyz),
y(xyz),
z(xyz) {};
55 return std::sqrt(
x *
x +
y *
y +
z *
z);
83 return v.
x * w.
x + v.
y * w.
y + v.
z * w.
z;
109 return Vec3<T>(lhs * rhs.
x, lhs * rhs.
y, lhs * rhs.
z);
160 return lhs.
x == rhs.
x && lhs.
y == rhs.
y && lhs.
z == rhs.
z;
168 template <
typename T>
struct Vec4
180 Vec4(
const T &xyz) :
x(xyz),
y(xyz),
z(xyz),
w(1) {};
218 #pragma region matrix
224 template <
typename T>
struct Mat3
282 Mat3(
const T &m00,
const T &m01,
const T &m02,
const T &m10,
const T &m11,
const T &m12,
const T &m20,
const T &m21,
const T &m22)
304 return Mat3<T>(1, 0, 0, 0, 1, 0, 0, 0, 1);
339 for (
int i = 0; i < 3; ++i)
341 for (
int j = 0; j < 3; ++j)
343 m.
data[i][j] = lhs * rhs.
data[i][j];
354 template <
typename T>
struct Mat4
404 Mat4(
const T &m00,
const T &m01,
const T &m02,
const T &m03,
const T &m10,
const T &m11,
const T &m12,
const T &m13,
const T &m20,
const T &m21,
const T &m22,
const T &m23,
const T &m30,
const T &m31,
const T &m32,
const T &m33)
433 return Mat4<T>(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
443 return Mat4<T>(-1, 0, 0, 0, 0, -1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1);
454 return Mat4<T>(1, 0, 0, v.
x, 0, 1, 0, v.
y, 0, 0, 1, v.
z, 0, 0, 0, 1);
469 a.
x * a.
x * (1 - cos(angle)) + cos(angle),
470 a.
x * a.
y * (1 - cos(angle)) - a.
z * sin(angle),
471 a.
x * a.
z * (1 - cos(angle)) + a.
y * sin(angle),
474 a.
y * a.
x * (1 - cos(angle)) + a.
z * sin(angle),
475 a.
y * a.
y * (1 - cos(angle)) + cos(angle),
476 a.
y * a.
z * (1 - cos(angle)) - a.
x * sin(angle),
479 a.
z * a.
x * (1 - cos(angle)) - a.
y * sin(angle),
480 a.
z * a.
y * (1 - cos(angle)) + a.
x * sin(angle),
481 a.
z * a.
z * (1 - cos(angle)) + cos(angle),
515 for (
int i = 0; i < 4; ++i)
517 for (
int j = 0; j < 4; ++j)
519 for (
int k = 0; k < 4; ++k) m.
data[i][j] += lhs.
data[i][k] * rhs.
data[k][j];
526 #pragma region matrixvectoroperations
538 lhs.
data[0][0] * rhs.
x + lhs.
data[0][1] * rhs.
y + lhs.
data[0][2] * rhs.
z,
539 lhs.
data[1][0] * rhs.
x + lhs.
data[1][1] * rhs.
y + lhs.
data[1][2] * rhs.
z,
540 lhs.
data[2][0] * rhs.
x + lhs.
data[2][1] * rhs.
y + lhs.
data[2][2] * rhs.
z
static Mat4< T > inversion()
Generate a spatial inversion operation, acting on a three-dimensional vector with fourth entry of uni...
Definition: Geometry.hpp:441
Vec4(const T &xyz)
Construct a new Vec4 object and initialize the x, y, and z components. The w component is set to unit...
Definition: Geometry.hpp:180
bool operator==(const Vec3< T > &lhs, const Vec3< T > &rhs)
Comparison of two Vec3 objects.
Definition: Geometry.hpp:158
Vec4()
Construct a new Vec4 object with uninitialized components.
Definition: Geometry.hpp:173
T y
y Component.
Definition: Geometry.hpp:202
Mat3(const Vec3< T > &a0, const Vec3< T > &a1, const Vec3< T > &a2)
Construct a new Mat3 object and initialize the column vectors.
Definition: Geometry.hpp:256
Vec3()
Construct a new Vec3 object with uninitialized values.
Definition: Geometry.hpp:26
Vec3< T > cross(const Vec3< T > &v, const Vec3< T > &w)
Compute the cross producdt of two Vec3 objects.
Definition: Geometry.hpp:94
T dot(const Vec3< T > &v, const Vec3< T > &w)
Compute the dot product of two Vec3 objects.
Definition: Geometry.hpp:81
Mat3(const T &m)
Construct a new Mat3 and initialize all entries with the same value.
Definition: Geometry.hpp:236
T determinant() const
Calculate the determinant of a Mat3 object.
Definition: Geometry.hpp:312
Three-dimensional vector.
Definition: Geometry.hpp:21
Mat3()
Construct a new Mat3 with uninitialized values.
Definition: Geometry.hpp:229
Mat4(const T &m00, const T &m01, const T &m02, const T &m03, const T &m10, const T &m11, const T &m12, const T &m13, const T &m20, const T &m21, const T &m22, const T &m23, const T &m30, const T &m31, const T &m32, const T &m33)
Construct a new Mat 4 object and initialize entires.
Definition: Geometry.hpp:404
Mat4(const T &m)
Construct a new Mat4 object and initialize all entries with the same value.
Definition: Geometry.hpp:364
Vec3< T > operator*(const T lhs, const Vec3< T > &rhs)
Scalar left-multiplication of a Vec3 object.
Definition: Geometry.hpp:107
T z
z Component.
Definition: Geometry.hpp:46
Vec4(const T &x, const T &y, const T &z)
Construct a new Vec4 object and initialize the x, y, and z components. The w component is set to unit...
Definition: Geometry.hpp:189
Mat3(const T &m00, const T &m01, const T &m02, const T &m10, const T &m11, const T &m12, const T &m20, const T &m21, const T &m22)
Construct a new Mat3 object and initialize entries.
Definition: Geometry.hpp:282
Mat4()
Construct a new Mat4 object with uninitialized entries.
Definition: Geometry.hpp:359
3x3 dimensional matrix.
Definition: Geometry.hpp:224
Four-dimensional vector.
Definition: Geometry.hpp:168
T w
w Component.
Definition: Geometry.hpp:204
static Mat4< T > identity()
Generate a 4x4 identity matrix.
Definition: Geometry.hpp:431
T y
y Component.
Definition: Geometry.hpp:45
static Mat4< T > rotation(const Vec3< T > &axis, const Vec3< T > &point, const T &angle)
Generate a spatial rotation around a specific rotation center and axis by a specific angle,...
Definition: Geometry.hpp:498
T data[4][4]
Matrix entries in row-major format.
Definition: Geometry.hpp:424
Vec3(const T &xyz)
Construct a new Vec3 object and initialize all numbers with the same value.
Definition: Geometry.hpp:33
T z
z Component.
Definition: Geometry.hpp:203
T x
x Component.
Definition: Geometry.hpp:42
static Mat4< T > rotation(const Vec3< T > &axis, T angle)
Generate a spatial rotation around a specific axis by a specific angle, acting on a three-dimensional...
Definition: Geometry.hpp:464
Vec3< T > operator+(const Vec3< T > &lhs, const Vec3< T > &rhs)
Addition of two Vec3 objects.
Definition: Geometry.hpp:120
4x4 dimensional matrix.
Definition: Geometry.hpp:354
T x
x Component.
Definition: Geometry.hpp:199
T data[3][3]
Matrix entries in row-major order.
Definition: Geometry.hpp:295
T norm() const
Compute the Euclidean norm of a Vec3 object.
Definition: Geometry.hpp:53
Vec3< T > operator-(const Vec3< T > &lhs, const Vec3< T > &rhs)
Subtraction of two Vec3 objects.
Definition: Geometry.hpp:133
static Mat3< T > identity()
Generate a 3x3 identity matrix.
Definition: Geometry.hpp:302
Mat3< T > inverse() const
Calculate the inverse of a matrix.
Definition: Geometry.hpp:322
Vec3 & normalize()
Normalize the Vec3 object with respect to its Euclidean norm.
Definition: Geometry.hpp:63
static Mat4< T > translation(const Vec3< T > &v)
Generate a spatial translation operation, acting on a three-dimensional vector with fourth entry of u...
Definition: Geometry.hpp:452