Starter questions topic!

Hello everyone!My name is George!I’m creating this post just to ask questions as I go along learning about CUDA and to avoid creating meaningless topics every time I want to ask something! I’m reading the manual that nVidia offers and I have a problem concerning a specific statement (actually 2 statements)!

First one:
int i = blockIdx.x * blockDim.x + threadIdx.x;

Why is that done?!How is a programmer supposed to reach to that conclusion?!I can only see that this is the threadID of a thread inside that grid of blocks of threads!Am I right?!
and also how is the dimension of the grid derived?!Why it is

dim3 dimGrid((N+dimBlock.x-1)/dimBlock.x, (N+dimBlock.y-1)/dimBlock.y);

These are all taken from page 7 where the manual says about matrix addition!Thanx in advance!

Sorryyyyyyyyyyyyyyy wrong category please move it whenever possible!