1 #ifndef VTESTBED_GEOMETRY_INERTIA_TENSOR_HH 2 #define VTESTBED_GEOMETRY_INERTIA_TENSOR_HH 4 #include <vtestbed/geometry/types.hh> 13 union { T x{}; T xx; };
14 union { T y{}; T yy; };
15 union { T xy{}; T yx; };
17 inline void scale(T factor) { x *= factor, y *= factor, xy *= factor; }
26 union { T x{}; T xx; };
27 union { T y{}; T yy; };
28 union { T z{}; T zz; };
29 union { T yz{}; T zy; };
30 union { T xz{}; T zx; };
31 union { T xy{}; T yx; };
35 x *= factor, y *= factor, z *= factor,
36 xy *= factor, xz *= factor, yz *= factor;
47 Vertex<T,2> centre{T{}};
48 union { T mass{}; T area; };
51 translate(
const Vertex<T,2>& origin) {
52 Vertex<T,2> delta = origin - centre;
53 inertia.xx += mass*delta(1)*delta(1);
54 inertia.yy += mass*delta(0)*delta(0);
55 inertia.xy += mass*delta(0)*delta(1);
63 Vertex<T,3> centre{T{}};
64 union { T mass{}; T volume; };
69 check_matrix(
const char* name,
const Matrix<T,3>& m,
const Matrix<T,3>& im);
75 #endif // vim:filetype=cpp