5#ifndef UTILS_VECTOR_MATH_H
6#define UTILS_VECTOR_MATH_H
24 vec2d(
const float _x,
const float _y) :
x(_x),
y(_y) {}
27 float dot(
const vec2d& other)
const {
return this->x * other.
x + this->y * other.
y; }
35 vec2d add(
const float mult)
const {
return vec2d(this->x + mult, this->y + mult); }
60 vec3d(
const float _x,
const float _y,
const float _z) :
vec2d(_x, _y),
z(_z) {}
99 vec4d(
const float _x,
const float _y,
const float _z,
const float _w) :
vec3d(_x, _y, _z),
w(_w) {}
170 void from_angles_XYZ(
const float x_rad,
const float y_rad,
const float z_rad);
180 void from_angles_ZYX(
const vec3d& angles_rad);
Program scope.
Definition: control_fixed_modes.hpp:12
Represent an XYZ rotation matrix.
Definition: vector_math.h:133
float R11
row 1, index 1
Definition: vector_math.h:135
float R31
row 3, index 1
Definition: vector_math.h:145
float R32
row 3, index 2
Definition: vector_math.h:146
float R22
row 2, index 2
Definition: vector_math.h:141
vec3d col2() const
Access the matrix by columns.
Definition: vector_math.h:150
void from_angles_XYZ(const float x_rad, const float y_rad, const float z_rad)
create a rotation matrix from three angles in radian (XYZ)
Definition: vector_math.cpp:33
float R13
row 1, index 3
Definition: vector_math.h:137
vec3d transform(const vec3d &vec) const
transform a vector by this rotation
Definition: vector_math.cpp:7
vec3d col1() const
Access the matrix by columns.
Definition: vector_math.h:149
float R23
row 2, index 3
Definition: vector_math.h:142
float R33
row 3, index 3
Definition: vector_math.h:147
float R12
row 1, index 2
Definition: vector_math.h:136
vec3d row1() const
Access the matrix by row.
Definition: vector_math.h:153
RotationMatrix compose(const RotationMatrix &other) const
Compose this roation with another.
Definition: vector_math.cpp:16
vec3d col3() const
Access the matrix by columns.
Definition: vector_math.h:151
float R21
row 2, index 1
Definition: vector_math.h:140
vec3d row2() const
Access the matrix by row.
Definition: vector_math.h:154
vec3d row3() const
Access the matrix by row.
Definition: vector_math.h:155
2d vector in any space
Definition: vector_math.h:15
vec2d(const float _x, const float _y)
Construct by parametersr.
Definition: vector_math.h:24
float dot(const vec2d &other) const
Dot product in 2D, representing the arcos of the angle between this vector and another.
Definition: vector_math.h:27
vec2d add(const vec2d &other) const
Coefficient wise addition.
Definition: vector_math.h:33
vec2d & operator=(const vec2d &other)
Copy operator.
Definition: vector_math.h:38
vec2d multiply(const vec2d &other) const
Coefficient wise multiplication.
Definition: vector_math.h:29
vec2d multiply(const float mult) const
Coefficient wise multiplication by a constant.
Definition: vector_math.h:31
vec2d add(const float mult) const
Coefficient wise addition by a constant.
Definition: vector_math.h:35
vec2d(const vec2d &other)=default
Construct by copy.
float x
x coordinate in 2D
Definition: vector_math.h:16
float y
y coordinate in 2D
Definition: vector_math.h:17
vec2d()
Default constructor.
Definition: vector_math.h:20
3d vector in any space
Definition: vector_math.h:54
vec3d add(const vec3d &other) const
Coefficient wise addition.
Definition: vector_math.h:71
vec3d(const vec2d &res, const float _z)
Construct by 2D vector and parameter.
Definition: vector_math.h:62
float dot(const vec3d &other) const
Dot product in 3D, representing the arcos of the angle between this vector and another.
Definition: vector_math.h:65
vec3d multiply(const vec3d &other) const
Coefficient wise multiplication.
Definition: vector_math.h:67
vec3d & operator=(const vec3d &other)
Copy operator.
Definition: vector_math.h:76
vec3d(const float _x, const float _y, const float _z)
Construct by parameters.
Definition: vector_math.h:60
vec3d multiply(const float mult) const
Coefficient wise multiplication by a constant.
Definition: vector_math.h:69
vec3d add(const float mult) const
Coefficient wise addition by a constant.
Definition: vector_math.h:73
vec3d()
Default constructor.
Definition: vector_math.h:58
float z
z coordinate of a 3D vector
Definition: vector_math.h:55
4d vector in any space
Definition: vector_math.h:93
vec4d(const float _x, const float _y, const float _z, const float _w)
Construct from parameters.
Definition: vector_math.h:99
float w
4d part of the coordinate
Definition: vector_math.h:94
vec4d & operator=(const vec4d &other)
Egality affectation.
Definition: vector_math.h:115
vec4d add(const float mult) const
Coefficient wise addition by a constant.
Definition: vector_math.h:112
vec4d()
Default constructor.
Definition: vector_math.h:97
float dot(const vec4d &other) const
Dot product, representing the angle arcos from this vector to another.
Definition: vector_math.h:104
vec4d(const vec3d &res, const float _w)
Construct from 3D and 4D part.
Definition: vector_math.h:101
vec4d multiply(const vec4d &other) const
Coefficient wise multiplication.
Definition: vector_math.h:106
vec4d multiply(const float mult) const
Coefficient wise multiplication by a constant.
Definition: vector_math.h:108
vec4d add(const vec4d &other) const
Coefficient wise addition.
Definition: vector_math.h:110