I'm trying to compute the partial derivative for ($x = $PX) where ($P$) is a Projection Matrix and $X$ is the World Space coordinates and $x$ is the image space coordinates. We have $$ {p_{3,4} = \begin{pmatrix}a_{11}&a_{12}&a_{13}&a_{14}\\ a_{21}&a_{22}&a_{23}&a_{24}\\ a_{31}&a_{32}&a_{33}&a_{34}\end{pmatrix}}, \\ x = {a_{11} . X + a_{12} . Y +a_{13} . Z +a_{14} . 1 \over a_{31} . X + a_{32} . Y +a_{33} . Z +a_{34} . 1}, \\ y = {a_{21} . X + a_{22} . Y +a_{23} . Z +a_{24} . 1 \over a_{31} . X + a_{32} . Y +a_{33} . Z +a_{34} . 1},$$ We want: $$ {∂x\over ∂X} ,{∂x\over ∂Y}, {∂x\over ∂Z}, {∂y\over ∂X} ,{∂y\over ∂Y} ,{∂y\over ∂Z}$$ I started with the first one but I'm not sure if it is correct or not: $$({a_{11} \over {a_{11} . X + a_{12} . Y +a_{13} . Z +a_{14} . 1}} - {{a_{31}} \over {a_{31} . X + a_{32} . Y +a_{33} . Z +a_{34}}}) . x$$
Plz, correct me if I'm wrong(Sorry, I'm so bad at math). Thanks in advance.
Turning the discussion in the comments into an answer, each of the partial derivatives is a straightforward application of the quotient rule for derivatives. Once you’ve done one, you can probably figure out the pattern for the other five.
You can reduce the clutter a bit and find all of the partial derivatives “in bulk” by instead computing the Jacobian matrix of this map, the elements of which are all of the partial derivatives that you seek. An easy way to do this is to decompose it into the composition $f\circ g$ of $g:\mathbf X\mapsto P\mathbf X$ and the dehomogenizing function $f:(x,y,w)^T\mapsto(x/w,y/w)^T$ and apply the chain rule. Writing $P=[M\mid\mathbf p_4]$, the Jacobian matrix of $g$ is simply $M$, while the Jacobian matrix of $f$ is easily found to be $$\begin{bmatrix}\frac1w&0&-\frac x{w^2} \\ 0&\frac1w&-\frac y{w^2}\end{bmatrix}.$$ Their product is $$\begin{bmatrix}\frac1w&0&-\frac x{w^2} \\ 0&\frac1w&-\frac y{w^2}\end{bmatrix} \begin{bmatrix} a_{11}&a_{12}&a_{13} \\ a_{21}&a_{22}&a_{23} \\ a_{31}&a_{32}&a_{33} \end{bmatrix} = \begin{bmatrix} {a_{11}w-a_{31}x \over w^2} & {a_{12}w-a_{32}x \over w^2} & {a_{13}w-a_{33}x \over w^2} \\ {a_{21}w-a_{31}y \over w^2} & {a_{22}w-a_{32}y \over w^2} & {a_{23}w-a_{33}y \over w^2}\end{bmatrix}.$$ Substitute the elements $(x,y,w)^T$ of $P\mathbf X$ into this matrix to complete the calculation.