perspective matrix derivation Now there has already been an answer here in this stackexchange, but I don't understand certain aspects of it.  The author has MORE DETAILED DESCRIPTION HERE(#1) but the problem is he doesn't describe what the linear mapping is done or how is the frustum transformed into the bounding box, there's NOWHERE IN THE WORLD mentioned how these two subspaces overlap or one is transformed to the other, for example:

Is this how these two spaces exist and after projecting the point from inside the view frustum to the near plane a linear mapping is done where the author says:  

"Our input to the linear mapping is x=x_near, and our output is the x coordinate in NDC space y=x_ndc, whose range is [-1.0, 1.0]" from the above page

It looks as if he somehow connects a line from the frustum to the NDC space but not clear on how it is done e.g. does he connect the top left vertex to the top left front vertex of the NDC cube?   Are the four corners of the frustum mapped to four corners of the cube?

As much I'd like to make this answer self contained, I don't know if I can copy his materials in here, please be kind enough to check the link out and help me understand this. Thanks in advance.
The key trick is the perspective divide, This divides the position by the w component. 

If you swap z and w (using a identity matrix that has swapped 3rd and 4th rows) and then do a perspective divide you end up with a double pyramid with a angle between the side (FoV) of 90° if applied to a unit cube. 

Once you have that transformation you can remap you can do further remapping pre and post the swap to make the corners of the input and output match up. The well known algorithm to create a perspective matrix has all those remaps inlined as an optimization.