What is the signifigance of the Dot Product in World to Local Transformations?

Looking for help understanding why this World to Local Space function works.

I’m working my way through Buckland’s Programming Game AI By Example The following function is used in the book to convert a point from world space to an agent’s local coordinate space (its i hat and j hat are AgentHeading and AgentSide respectively)

    inline Vector2D PointToLocalSpace(const Vector2D &point,                              Vector2D &AgentHeading,                              Vector2D &AgentSide,                               Vector2D &AgentPosition) {      //make a copy of the point   Vector2D TransPoint = point;    //create a transformation matrix     C2DMatrix matTransform;    double Tx = -AgentPosition.Dot(AgentHeading);   double Ty = -AgentPosition.Dot(AgentSide);    //create the transformation matrix   matTransform._11(AgentHeading.x); matTransform._12(AgentSide.x);   matTransform._21(AgentHeading.y); matTransform._22(AgentSide.y);   matTransform._31(Tx);           matTransform._32(Ty);    //now transform the vertices   matTransform.TransformVector2Ds(TransPoint);    return TransPoint; } 

I’ve been learning about vectors and matrices for the last three weeks and still I’m having a lot of trouble understanding why this works in terms of vectors and matrices. What is the reason for using a a dot product in the translation coordinates? Why is it the dot product of the agent’s position and its heading? What does this dot product correspond to geometrically?

Why not just translate by the Agent’s position?

Are there any simpler ways of representing this algorithm?