This is an old utility method, new uses of which should be avoided.
For homogeneous transform arithmetic, just use
Unity's built-in Transform and matrix math support. The naming and use of Pose representation in this implementation can be confusing, so this explanation will avoid them and map back at the end. Conceptually, there are three things: a scaled transform T in world space, an unscaled transform A in T space, and an unscaled transform B in world space. The goal is to find a scaled transform T' (sharing the scale of T) such that an unmodified A in T' equals B when mapped to world space; colloquially, "find where we need to move T to so that A and B are on top of one another." Mathematically, this means the relationship between T' and B is the same as the relationship between T and A; thus, if we find T in the space of A (or, more precisely, A as a scaled transform in world space), we can use that same relationship with B to find T'. This gives us the following arithmetic (treating each transform as a "local to world" matrix):
given T, A, and B
A_inWorldSpace := T * A
T_inASpace := inverse(A_inWorldSpace) * T
T' := b * T_inASpace
Mapping this back to the variables and assumptions of this implementation, localToWorld is T, local is A, and world is B. The fact that the result T' is a scaled transform is not reflected in the return value of this extension and is instead implicit in its usage. The position and rotation of the returned Pose must be assigned directly to the corresponding fields of the Transform which provided localToWorld, without modifying the scale of that Transform; any other usage may not yield the desired alignment.
ParameterslocalToWorldT (see remarks for details).
localA (see remarks for details).
worldB (see remarks for details).
ReturnsT', excluding scale (see remarks for details).