Question about b2Transform

Hello everyone!
I'm a beginner in Box2d.
Through reading the document and source code of Box2d, I still can not get the meaning of the structure 'b2Transform'.

I've already known there is a rotation matrix and a position vector in the structure of b2Transform, but I can not understand the use of it, why we use it everywhere.

For example:
We use it when testing whether a point is in a shape
bool in_or_not = shape->TestPoint(transform, point);

It appears when cast a ray to a shape:
bool hit = shape->RayCast(&output, input, transform);

It also appears when calculating the position of a shape in the 'world'
const b2Transform& xf = fixture->GetBody()->GetTransform();
b2Vec2 vertices_in_world=b2Mul(xf, poly->m_vertices[i]);

Can any one tell me what the use of b2Transform is and why we use it in the statements above?

Thanks!
Box2D simulates rigid body physics which means that a body can move around, but the shapes attached to it should remain fixed relative to the body.
That's why shape positions are only defined once relative to their body, and thereafter the body transform is used to define where they are located.

This means less calculations are necessary - for example if you have a body with ten polygon shapes attached to it, when this body moves you only need to update the body's transform, not the vertices of every polygon.
It also means better accuracy - if you updated the positions of each vertex in the shapes every frame, over time their positions would stray due to floating point calculation rounding.
irresistible force wrote:
Box2D simulates rigid body physics which means that a body can move around, but the shapes attached to it should remain fixed relative to the body.
That's why shape positions are only defined once relative to their body, and thereafter the body transform is used to define where they are located.

This means less calculations are necessary - for example if you have a body with ten polygon shapes attached to it, when this body moves you only need to update the body's transform, not the vertices of every polygon.
It also means better accuracy - if you updated the positions of each vertex in the shapes every frame, over time their positions would stray due to floating point calculation rounding.


So, b2Transform hold the data of the position in the world and rotation around the mass center of body, and shape only hold the position according to the shape. Because of this, we should use b2Transform to calculate the position of shape in the b2World.
Am I right?
I feel much clear now, thank you for your guide!

Original thread: https://box2d.org/forum/viewtopic.php?t=7471