19 #pragma GCC optimize("O3") 28 float cp = cosf(pitch);
29 float sp = sinf(pitch);
30 float sr = sinf(roll);
31 float cr = cosf(roll);
36 a.y = (sr * sp * cy) - (cr * sy);
37 a.z = (cr * sp * cy) + (sr * sy);
39 b.y = (sr * sp * sy) + (cr * cy);
40 b.z = (cr * sp * sy) - (sr * cy);
51 if (pitch !=
nullptr) {
54 if (roll !=
nullptr) {
55 *roll = atan2f(c.y, c.z);
58 *yaw = atan2f(b.x, a.x);
69 (*this).a.rotate(rotation);
70 (*this).b.rotate(rotation);
71 (*this).c.rotate(rotation);
94 float c3 = cosf(pitch);
95 float s3 = sinf(pitch);
96 float s2 = sinf(roll);
97 float c2 = cosf(roll);
101 a.x = c1 * c3 - s1 * s2 * s3;
105 a.z = s3*c1 + c3*s2*s1;
106 b.x = c3*s1 + s3*s2*c1;
107 b.z = s1*s3 - s2*c1*c3;
114 template <
typename T>
118 temp_matrix.
a.x = a.y * g.
z - a.z * g.
y;
119 temp_matrix.
a.y = a.z * g.
x - a.x * g.
z;
120 temp_matrix.
a.z = a.x * g.
y - a.y * g.
x;
121 temp_matrix.
b.x = b.y * g.
z - b.z * g.
y;
122 temp_matrix.
b.y = b.z * g.
x - b.x * g.
z;
123 temp_matrix.
b.z = b.x * g.
y - b.y * g.
x;
124 temp_matrix.
c.x = c.y * g.
z - c.z * g.
y;
125 temp_matrix.
c.y = c.z * g.
x - c.x * g.
z;
126 temp_matrix.
c.z = c.x * g.
y - c.y * g.
x;
128 (*this) += temp_matrix;
134 template <
typename T>
141 a = t0 * (1.0f / t0.
length());
142 b = t1 * (1.0f / t1.
length());
143 c = t2 * (1.0f / t2.
length());
147 template <
typename T>
151 b.x * v.
x + b.y * v.
y + b.z * v.
z,
152 c.x * v.
x + c.y * v.
y + c.z * v.
z);
156 template <
typename T>
160 b.x * v.
x + b.y * v.
y + b.z * v.
z);
164 template <
typename T>
168 a.y * v.
x + b.y * v.
y + c.y * v.
z,
169 a.z * v.
x + b.z * v.
y + c.z * v.
z);
173 template <
typename T>
177 a.x * m.
a.y + a.y * m.
b.y + a.z * m.
c.y,
178 a.x * m.
a.z + a.y * m.
b.z + a.z * m.
c.z),
180 b.x * m.
a.y + b.y * m.
b.y + b.z * m.
c.y,
181 b.x * m.
a.z + b.y * m.
b.z + b.z * m.
c.z),
183 c.x * m.
a.y + c.y * m.
b.y + c.z * m.
c.y,
184 c.x * m.
a.z + c.y * m.
b.z + c.z * m.
c.z));
188 template <
typename T>
196 template <
typename T>
199 return a.x * (b.y * c.z - b.z * c.y) +
200 a.y * (b.z * c.x - b.x * c.z) +
201 a.z * (b.x * c.y - b.y * c.x);
204 template <
typename T>
213 inv.
a.x = (b.y * c.z - c.y * b.z) / d;
214 inv.
a.y = (a.z * c.y - a.y * c.z) / d;
215 inv.
a.z = (a.y * b.z - a.z * b.y) / d;
216 inv.
b.x = (b.z * c.x - b.x * c.z) / d;
217 inv.
b.y = (a.x * c.z - a.z * c.x) / d;
218 inv.
b.z = (b.x * a.z - a.x * b.z) / d;
219 inv.
c.x = (b.x * c.y - c.x * b.y) / d;
220 inv.
c.y = (c.x * a.y - a.x * c.y) / d;
221 inv.
c.z = (a.x * b.y - b.x * a.y) / d;
226 template <
typename T>
237 template <
typename T>
247 template <
typename T>
250 float C = cosf(theta);
251 float S = sinf(theta);
void to_euler(float *roll, float *pitch, float *yaw) const
Vector3< T > normalized() const
Vector2< T > mulXY(const Vector3< T > &v) const
void from_axis_angle(const Vector3< T > &v, float theta)
void from_euler(float roll, float pitch, float yaw)
Matrix3< T > transposed(void) const
bool is_zero(const T fVal1)
Vector3< T > to_euler312() const
void from_rotation(enum Rotation rotation)
Matrix3< T > operator*(const T num) const
float safe_asin(const T v)
Vector3< T > mul_transpose(const Vector3< T > &v) const
void from_euler312(float roll, float pitch, float yaw)
bool inverse(float x[], float y[], uint16_t dim)
#define error(fmt, args ...)
bool inverse(Matrix3< T > &inv) const
void rotate(const Vector3< T > &g)