all you need to do is measure how the vectors vec3(1,0,0) vec3 (0,1,0) vec3(0,0,1) get changed by any matrix.
vec3(1,0,0)'s transformation is equal to the first column of the matrix
vec3(0,1,0)'s transformation is equal to the second column of the matrix
vec3(0,0,1)'s transformation is equal to the second column of the matrix (only if it has 3 dimensions)
vec4(0,0,0,1)'s transformation is equal to the second column of the matrix (only if it has 4 dimensions),...
yes, learn how matrices function on basic core level:
in a 2d to 2d matrix transformation, 2 matrix colums are equal to what the 2 base-vectors vec2(1,0) and vec2(0,1) are changed into by the matrix. any scalar of that is also transformed linearily scaled to that, as a matrix transformation is a linear transformation.
in a 3d to 3d matrix transformation, same goes for 3 base-vectors vec3(1,0,0) vec3 (0,1,0) vec3(0,0,1) being changed by 3 matrix columns.
in a 3d to 2d matrix, 3 columns of 2 lines tell how 3 3d basis vectors as in the above are scamed in 3d space, as a sum of three 2d vectors (that get scaled by the matrix).
Here's a way of doing what I think you want to do.
First, find two perpendicular unit-vectors that are parallel to the plane (i.e. perpendicular to the normal vector). You might want to use Gram-Schmidt here. Call the vectors $u_1$ and $u_2$. These are the "axes" along the plane you're projecting onto.
Any point on the plane can be written in the form $a_1u_1 + a_2u_2$ for some coordinates $(a_1,a_2)$. To find the coordinates of the orthogonal projection of a vector $x$ onto your plane, calculate
$$
a_1 = u_1^Tx\\
a_2 = u_2^Tx
$$
Or, all together:
$$
\pmatrix{a_1\\a_2} = \pmatrix{u_1^T\\u_2^T} \pmatrix{x_1\\x_2\\x_3}
$$
Best Answer
Your goal should be finding a suitable $2\times3$ matrix which you multiply with your 3D vector to obtain the projected 2D vector.
I assume that $e_1, e_2, e_3$ are both unit length and orthogonal to one another, i.e. that you're dealing with an orthogonal coordinate system in 3D. All 3D vectors are assumed to be expressed in this coordinate system. Without orthogonality, you'd have trouble matchiung the relation of $e_1', e_2', n$ to that of $e_1,e_2,e_3$, as $n$ is orthogonal to $e_1',e_2'$.
You first need to find a vector $e_1'$ which should be unit length, lie in the plane, but may be rotated about the origin in an arbitrary way. One way to achieve this is by choosing an arbitrary vector $v$, and computing the cross product between $v\times n$. The resulting vector will always be orthogonal to $n$. If you are unlucky, $v$ might be parallel to $n$, in which case the cross product has length zero. So in the possible presence of numerical complications (i.e. rounding errors, so you won't get an exact zero), it might be easiest to try $e_1,e_2,e_3$ as $v$, and choose the result with maximal length. Then normalize its length to 1, and you have a suitable $e_1'$.
Next, you compute $e_2'$ as the cross product of $e_1'$ and $n$. Depending on the way $e_1,e_2,e_3$ relate to one another, you'll have to do this either in one or in the other order to end up with the correct sign for $e_1$. Simply try them out. The length of the result should already be unit length, at least if $n$ had unit length and $e_1'$ was chosen as described above.
Now that you have $e_1'$ and $e_2'$, you can simply use these as the rows of your desired projection matrix. The rationale here is as follows: the matrix times vector multiplication will compute two scalar products, which correspond to the portion of your input vector which lies in the direction of that vector, i.e. the length of the orthogonal projection along one direction. Take two of these, and you have coordinates in a coordinate system within the plane, obtained from orthogonal projection onto that plane.