Compute affine matrix using direction, spacing and origin

I want to compute the affine matrix manually for the image to convert between world and voxel coordinates. How can I do that using direction, spacing and origin that is returned using SimpleITK?

This may answer your question.
Refer to [SOLVED]TransformIndexToPhysicalPoint manually - #9 by rolof - Beginner Questions - ITK