47 const auto r_squared = r * r;
48 const auto area = r_squared *
Pi;
57 const auto r_squared =
Area{r * r};
58 const auto circle_area = r_squared *
Pi;
59 const auto circle_mass = density * circle_area;
60 const auto d = v1 - v0;
63 const auto h = r *
Real{2};
64 const auto rect_mass = density * b * h;
65 const auto totalMass = circle_mass + rect_mass;
66 const auto center = (v0 + v1) / 2;
70 const auto halfCircleArea = circle_area / 2;
71 const auto halfRSquared = r_squared / 2;
86 return MassData{center, totalMass, I};
118 const auto count =
size(vertices);
138 const auto s =
Average(vertices);
140 for (
auto i = decltype(count){0}; i < count; ++i)
143 const auto e1 = vertices[i] - s;
146 const auto D =
Cross(e1, e2);
149 const auto triangleArea = D * RealReciprocalOfTwo;
150 area += triangleArea;
154 center +=
StripUnit(triangleArea) * (e1 + e2) * RealReciprocalOfThree;
160 const auto triangleI = D * (intx2 + inty2) * RealReciprocalOfTwelve;
170 const auto massDataCenter = center + s;
176 const auto inertialLever = massCenterOffset - centerOffset;
179 return MassData{massDataCenter, mass, massDataI};
192 for (
auto&& f: body.GetFixtures())
194 const auto& fixture =
GetRef(f);
195 if (fixture.GetDensity() > 0_kgpm2)
198 mass +=
Mass{massData.mass};