|
|
|
@ -15,6 +15,15 @@ struct Vec3f {
@@ -15,6 +15,15 @@ struct Vec3f {
|
|
|
|
|
Vec3f(float x, float y, float z); |
|
|
|
|
Vec3f(const mpud::float_axes_t& axes); |
|
|
|
|
|
|
|
|
|
Vec3f operator*(float s) const { return {s * x, s * y, s * z}; } |
|
|
|
|
|
|
|
|
|
Vec3f& operator*=(float s) { |
|
|
|
|
x *= s; |
|
|
|
|
y *= s; |
|
|
|
|
z *= s; |
|
|
|
|
return *this; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Vec3f operator+(const Vec3f& a) const { return {x + a.x, y + a.y, z + a.z}; } |
|
|
|
|
|
|
|
|
|
Vec3f& operator+=(const Vec3f& a) { |
|
|
|
@ -23,17 +32,44 @@ struct Vec3f {
@@ -23,17 +32,44 @@ struct Vec3f {
|
|
|
|
|
z += a.z; |
|
|
|
|
return *this; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
float dot(const Vec3f& v) const { |
|
|
|
|
return x * v.x + y * v.y + z * v.z; |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
struct Mat3f { |
|
|
|
|
float xx, xy, xz; |
|
|
|
|
float yx, yy, yz; |
|
|
|
|
float zx, zy, zz; |
|
|
|
|
union { |
|
|
|
|
Vec3f rx; |
|
|
|
|
float xx, xy, xz; |
|
|
|
|
}; |
|
|
|
|
union { |
|
|
|
|
Vec3f ry; |
|
|
|
|
float yx, yy, yz; |
|
|
|
|
}; |
|
|
|
|
union { |
|
|
|
|
Vec3f rz; |
|
|
|
|
float zx, zy, zz; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
Mat3f(Vec3f rx_, Vec3f ry_, Vec3f rz_) |
|
|
|
|
: rx(rx_), ry(ry_), rz(rz_) {} |
|
|
|
|
|
|
|
|
|
Mat3f(float xx, float xy, float xz, float yx, float yy, float yz, float zx, |
|
|
|
|
float zy, float zz) |
|
|
|
|
: rx(xx, xy, xz), ry(yx, yy, yz), rz(zx, zy, zz) {} |
|
|
|
|
|
|
|
|
|
Vec3f operator*(const Vec3f& v) const { |
|
|
|
|
return {xx * v.x + xy * v.y + xz * v.z, |
|
|
|
|
yx * v.x + yy * v.y + yz * v.z, |
|
|
|
|
zx * v.x + zy * v.y + zz * v.z}; |
|
|
|
|
return {rx.dot(v), ry.dot(v), rz.dot(v)}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Mat3f transpose() const { |
|
|
|
|
return {xx, yx, zx, xy, yy, zy, xz, yz, zz}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Mat3f operator*(const Mat3f& m) const { |
|
|
|
|
Mat3f mt = m.transpose(); |
|
|
|
|
return {mt * rx, mt * ry, mt * rz}; |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|