33 const float hx = 0.5f, hy = 1.5f;
34 const float angle1 = 0.25f;
42 polygon1.
SetAsBox(hx, hy, center, angle1);
51 vertices[0].
Set(center.
x - hx, center.
y - hy);
52 vertices[1].
Set(center.
x + hx, center.
y - hy);
53 vertices[2].
Set(center.
x - hx, center.
y + hy);
54 vertices[3].
Set(center.
x + hx, center.
y + hy);
57 polygon2.
Set(vertices, 4);
62 const float mass = 4.0f * hx * hy;
63 const float inertia = (mass / 3.0f) * (hx * hx + hy * hy) + mass *
b2Dot(center, center);
70 CHECK(
b2Abs(massData1.
mass - mass) < 20.0f * (absTol + relTol * mass));
71 CHECK(
b2Abs(massData1.
I - inertia) < 40.0f * (absTol + relTol * inertia));
78 CHECK(
b2Abs(massData2.
mass - mass) < 20.0f * (absTol + relTol * mass));
79 CHECK(
b2Abs(massData2.
I - inertia) < 40.0f * (absTol + relTol * inertia));
float mass
The mass of the shape, usually in kilograms.
float b2Dot(const b2Vec2 &a, const b2Vec2 &b)
Perform the dot product on two vectors.
b2Vec2 center
The position of the shape's centroid relative to the shape's origin.
void ComputeMass(b2MassData *massData, float density) const override
DOCTEST_TEST_CASE("collision test")
void SetAsBox(float hx, float hy)
void Set(float x_, float y_)
Set this vector to some specified coordinates.
float I
The rotational inertia of the shape about the local origin.
void Set(const b2Vec2 *points, int32 count)
This holds the mass data computed for a shape.