1

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.

Y. A.
  • 13
  • Just apply the quotient rule to each component separately.. – amd Jun 22 '19 at 23:36
  • 1
    @amd Can you please explain more as I'm so bad at math. Thanks. – Y. A. Jun 23 '19 at 00:07
  • https://en.m.wikipedia.org/wiki/Quotient_rule. The way to get better at it is by doing. – amd Jun 23 '19 at 00:10
  • 1
    @amd Awesome. This is what I got so far, Plz tell me if it is right or wrong so that I can do the others: $${∂x\over ∂X} = {{ -a_{31}a_{14} -a_{31}a_{12}Y-a_{31}a_{13}Z+a_{11}a_{32}Y+a_{11}a_{33}Z + a_{11} a_{34} }\over{({a_{31} X} + {a_{32} Y}+{a_{33} Z}+{a_{34}})^2}}$$ – Y. A. Jun 23 '19 at 00:41
  • Looks good to me. You can also do all this “in bulk” by computing the Jacobian of $P\mathbf X$ and multiplying it by the Jacobian of the dehomogenizing function. Less clutter in the calculations that way, and you can then substitute into the resulting matrix to get the full expressions. – amd Jun 23 '19 at 04:37

1 Answers1

0

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.

amd
  • 53,693