<p>The hint with the perspective division was already <a href="https://computergraphics.stackexchange.com/a/1607/127">mentioned by ratchet freak</a>, but I'd like to add some explanation of how to come up with the solution.</p>

<hr>

<p>First of all, remember that homogenous coordinates add a fourth value $w$ to your 3D vector. For points in the 3D space, $w \neq 0$ holds and $[x, y, z, w] = [n*x, n*y, n*z, n*w]$ also holds for every $n$.</p>

<p>Now the goal is to find a transformation matrix $T$, which solves</p>

<p>$$
    \begin{bmatrix} \frac{2}{x + y} \\ \frac{5y + z}{2x + 2y} \\ 3 \\ 1 \end{bmatrix}
= T \cdot 
\begin{bmatrix} x \\ y \\ z \\ 1 \end{bmatrix}
=
\begin{bmatrix} t_{11} &amp; t_{21} &amp; t_{31} &amp; t_{41}  \\ t_{12} &amp; t_{22} &amp; t_{32} &amp; t_{42} \\ t_{13} &amp; t_{23} &amp; t_{33} &amp; t_{43} \\ t_{14} &amp; t_{24} &amp; t_{34} &amp; t_{44} \end{bmatrix}
\cdot \begin{bmatrix} x \\ y \\ z \\ 1 \end{bmatrix}
$$</p>

<p>These are basically four equations, but having a look at the first row, being</p>

<p>$$\frac{2}{x + y} = t_{11}\cdot x + t_{21}\cdot y + t_{31} \cdot z + t_{41}$$</p>

<p>and trying to find values for the $t$s, you'll see that this is not possible without further restructuring. The main problems are the $x$ and $y$ in the denominator. But as we can make use of the fourth value in the vector, we can expand the $w$.</p>

<p>$$
\begin{bmatrix} \frac{2}{x + y} \\ \frac{5y + z}{2x + 2y} \\ 3 \\ 1 \end{bmatrix}
=
\begin{bmatrix} \frac{2}{x + y} \\ \frac{2.5y + 0.5z}{x + y} \\ 3 \\ 1 \end{bmatrix}
=
\begin{bmatrix} 2 \\ 2.5y + 0.5z \\ 3(x + y) \\ x + y \end{bmatrix}
$$</p>

<p>In the first step, I removed the factor of $2$ from the second values denominator, leading to every values denominator either being $1$ or $(x + y)$. In the second step, I made use of the above mentioned rule ($[x, y, z, w] = [n\cdot x, n\cdot y, n\cdot z, n\cdot w]$), setting $n = (x + y)$, thus eliminating the denominator of the first two values.</p>

<p>Now we've got</p>

<p>$$
\begin{bmatrix} 2 \\ 2.5y + 0.5z \\ 3(x + y) \\ x + y \end{bmatrix}
=
\begin{bmatrix} t_{11} &amp; t_{21} &amp; t_{31} &amp; t_{41}  \\ t_{12} &amp; t_{22} &amp; t_{32} &amp; t_{42} \\ t_{13} &amp; t_{23} &amp; t_{33} &amp; t_{43} \\ t_{14} &amp; t_{24} &amp; t_{34} &amp; t_{44} \end{bmatrix}
\cdot
\begin{bmatrix} x \\ y \\ z \\ 1 \end{bmatrix}
$$</p>

<p>which is not that hard anymore.</p>

<p>$$
\begin{bmatrix} 2 \\ 2.5y + 0.5z \\ 3(x + y) \\ x + y \end{bmatrix}
=
\begin{bmatrix} 0  &amp;  0 &amp;   0  &amp;  2   \\ 0 &amp;  2.5 &amp; 0.5 &amp;  0 \\ 3 &amp;   3  &amp;  0 &amp;   0 \\ 1  &amp;  1  &amp;  0  &amp;  0 \end{bmatrix}
\cdot
\begin{bmatrix} x \\ y \\ z \\ 1 \end{bmatrix}
$$</p>

<hr>

<h2>TL;DR</h2>

<ul>
<li>Remember the advantage of homogenous coordinates $w$.</li>
<li>$[x, y, z, w] = [n\cdot x, n\cdot y, n\cdot z, n\cdot w]$ is the key.</li>
<li>Push everything that's in the denominator to the $w$ coordinate.</li>
</ul>

CC BY-SA 3.0
2015-11-03T13:47:17.367Z
The original vector is  $(2/(x+y),(5y+z)/(2x+2y),3)$ while your expansion assumes  $(2/(x+y),5(y+z)/(2x+2y),3)$
ratchet freak
CC BY-SA 3.0
2015-11-03T15:36:09.700Z
@ratchetfreak Thanks for your comment. I corrected my mistake.
Nero
CC BY-SA 3.0
2015-10-14T18:02:21.180Z
2015-11-03T15:32:59.350Z
2017-04-13T13:00:43.660Z
Nero
<p>The hint is to use the perspective divide inherent in homegeneous coordinate. So the resulting point you are looking for is $(2, (5y+z)/2, 3x+3y, x+y)$</p>

<p>That matrix then ends up as</p>

<p>$$
\begin{bmatrix}
    0 &amp;  0 &amp;  0 &amp;  2  \\
    0 &amp;  2.5&amp; 0.5&amp; 0  \\
    3 &amp;  3 &amp;  0 &amp;  0  \\
    1 &amp;  1 &amp;  0 &amp;  0  \\
\end{bmatrix}
$$</p>

CC BY-SA 3.0
2015-10-09T18:51:18.327Z
While this answers the question, instead of simply providing the solution to the specific problem it would be much better to describe how the OP could come up with this solution on his own. The question clearly is a homework related question. As of now, this answer does not help to solve the problem with different numbers.
Nero
CC BY-SA 3.0
2015-10-09T19:02:02.020Z
Thank you. I just investigated what "perspective divide" is and I found it has to do with finding a w for (x, y, z) in order to get (x, y, z, w). After finding such a value then everything is straight forward. Is this correct? Also, the issue here is to get rid of the variables in denominator.
JORGE
CC BY-SA 3.0
2015-10-09T19:23:59.467Z
I wonder if I can ask another question related to this same problem. "Assume you have performed the projection on the canonical view volume.  Give the matrix you would use to make the final image of size 5 units wide and 3 units tall." I think the answer is [5, 0, 0, 0][0, 3, 0, 0][0, 0, 1, 0][0, 0, 0, 1] Am I correct?
JORGE
CC BY-SA 3.0
2015-10-10T09:05:55.533Z
@JORGE i guess you should update the original question. Please explain this topic or link useful resources. I am interested
psicomante
CC BY-SA 3.0
2015-10-10T15:52:28.570Z
@JORGE if it's a different question but relating to this one then you can post it separately as a new question but include a link to this question.
trichoplax is on Codidact now
CC BY-SA 3.0
2015-10-09T18:37:37.273Z
2015-11-03T12:54:16.087Z
2015-11-03T12:54:16.087Z
ratchet freak
<p>In homogeneous coordinates i would do something like this:</p>

<p>$$\vec{p} = \left(\frac{2}{x+y}, \frac{5y + z}{2x + 2y}, 3\right)^T = \left(\frac{2}{x+y}, \frac{\frac{5y + z}{2}}{x + y}, \frac{3x + 3y}{x + y}\right)^T$$ adding the fourth coordinate</p>

<p>$$\vec{p}^H = \left(2, \frac{5y + z}{2}, 3x + 3y, x + y\right)^T = 
\begin{pmatrix} 
 0 &amp; 0 &amp; 0 &amp; 2 \\ 
 0 &amp; \frac{5}{2} &amp; \frac{1}{2} &amp; 0 \\
 3 &amp; 3 &amp; 0 &amp; 0 \\
 1 &amp; 1 &amp; 0 &amp; 0
\end{pmatrix} \cdot \begin{pmatrix}x \\ y \\ z \\ 1\end{pmatrix}$$,</p>

<p>If you want a systematic way, since a linear transformation is completely characterized from the transformation of a basis, take the canonical bases i.e.
($\vec{e}^H_0 = (1,0,0,0), \vec{e}^H_1 = (0,1,0,0),...$) apply the transformation in $\vec{p}^H$ it will give you for $i = 0,...,3$ the columns of the matrix.</p>

CC BY-SA 3.0
2015-11-04T09:32:20.727Z
2015-11-04T09:32:20.727Z
user8469759
<p>I have the following problem:</p>

<p>Give a matrix that will transform the point $(x,y,z)$ into the point $(\frac{2}{x+y}, \frac{5y + z}{2x + 2y}, 3)$.</p>

<p>I have been reading my book to find a way to solve it without success. I will very much appreciate your feedback about how to solve it.</p>

CC BY-SA 3.0
2015-10-09T18:51:22.410Z
You can read off the matrix elements from the coefficients of x, y, z in the result. For instance if the result had 2x + 3y in one component, then the corresponding column of the matrix would have values (2, 3, 0). The problem in this case is a bit more complicated as it appears to be relying on homogeneous coordinates (since there's division by x and y in the result), but still you can basically read off the matrix elements from the form of the result.
Nathan Reed
CC BY-SA 3.0
2015-10-11T20:02:02.933Z
[Relevant meta discussion on whether multi part questions should be in one post or separate questions](http://meta.computergraphics.stackexchange.com/questions/181/editing-a-question-to-add-a-second-part)
trichoplax is on Codidact now
CC BY-SA 3.0
2015-10-11T20:08:12.620Z
I'd recommend asking the second part as a separate question, since there is already an answer that was based on there only being one part. I've rolled back to the previous edit with only one question, but I've also raised this on Meta to see how others see it.
trichoplax is on Codidact now
CC BY-SA 3.0
2015-10-11T20:14:33.037Z
I don't know what will be decided on Meta but I've rolled back the edit quickly rather than waiting for the outcome of the Meta discussion, in order to prevent new answers coming in for the second part that would then prevent the edit being rolled back. I don't mean this to seem pushy. If there's anything you'd like to discuss please feel free to join us in [chat].
trichoplax is on Codidact now
<transformations>
Transform a point into another point
JORGE
# Transform a point into another point

(Asked by: username_0 on 2015-10-09)

I have the following problem:

Give a matrix that will transform the point $(x,y,z)$ into the point $(\frac{2}{x+y}, \frac{5y + z}{2x + 2y}, 3)$.

I have been reading my book to find a way to solve it without success. I will very much appreciate your feedback about how to solve it.

**Tags:** transformations

> **Comments:**
> **username_1**: You can read off the matrix elements from the coefficients of x, y, z in the result. For instance if the result had 2x + 3y in one component, then the corresponding column of the matrix would have values (2, 3, 0). The problem in this case is a bit more complicated as it appears to be relying on homogeneous coordinates (since there's division by x and y in the result), but still you can basically read off the matrix elements from the form of the result.  
> **username_2**: [Relevant meta discussion on whether multi part questions should be in one post or separate questions](http://meta.computergraphics.stackexchange.com/questions/181/editing-a-question-to-add-a-second-part)  
> **username_2**: I'd recommend asking the second part as a separate question, since there is already an answer that was based on there only being one part. I've rolled back to the previous edit with only one question, but I've also raised this on Meta to see how others see it.  
> **username_2**: I don't know what will be decided on Meta but I've rolled back the edit quickly rather than waiting for the outcome of the Meta discussion, in order to prevent new answers coming in for the second part that would then prevent the edit being rolled back. I don't mean this to seem pushy. If there's anything you'd like to discuss please feel free to join us in [chat].  

---

## 3 answers

### Answer by username_3 on 2015-10-14. Score: 5

The hint with the perspective division was already [mentioned by username_4](https://computergraphics.stackexchange.com/a/1607/127), but I'd like to add some explanation of how to come up with the solution.

---

First of all, remember that homogenous coordinates add a fourth value $w$ to your 3D vector. For points in the 3D space, $w \neq 0$ holds and $[x, y, z, w] = [n\*x, n\*y, n\*z, n\*w]$ also holds for every $n$.

Now the goal is to find a transformation matrix $T$, which solves

$$
\begin{bmatrix} \frac{2}{x + y} \\ \frac{5y + z}{2x + 2y} \\ 3 \\ 1 \end{bmatrix}
= T \cdot
\begin{bmatrix} x \\ y \\ z \\ 1 \end{bmatrix}
=
\begin{bmatrix} t\_{11} & t\_{21} & t\_{31} & t\_{41} \\ t\_{12} & t\_{22} & t\_{32} & t\_{42} \\ t\_{13} & t\_{23} & t\_{33} & t\_{43} \\ t\_{14} & t\_{24} & t\_{34} & t\_{44} \end{bmatrix}
\cdot \begin{bmatrix} x \\ y \\ z \\ 1 \end{bmatrix}
$$

These are basically four equations, but having a look at the first row, being

$$\frac{2}{x + y} = t\_{11}\cdot x + t\_{21}\cdot y + t\_{31} \cdot z + t\_{41}$$

and trying to find values for the $t$s, you'll see that this is not possible without further restructuring. The main problems are the $x$ and $y$ in the denominator. But as we can make use of the fourth value in the vector, we can expand the $w$.

$$
\begin{bmatrix} \frac{2}{x + y} \\ \frac{5y + z}{2x + 2y} \\ 3 \\ 1 \end{bmatrix}
=
\begin{bmatrix} \frac{2}{x + y} \\ \frac{2.5y + 0.5z}{x + y} \\ 3 \\ 1 \end{bmatrix}
=
\begin{bmatrix} 2 \\ 2.5y + 0.5z \\ 3(x + y) \\ x + y \end{bmatrix}
$$

In the first step, I removed the factor of $2$ from the second values denominator, leading to every values denominator either being $1$ or $(x + y)$. In the second step, I made use of the above mentioned rule ($[x, y, z, w] = [n\cdot x, n\cdot y, n\cdot z, n\cdot w]$), setting $n = (x + y)$, thus eliminating the denominator of the first two values.

Now we've got

$$
\begin{bmatrix} 2 \\ 2.5y + 0.5z \\ 3(x + y) \\ x + y \end{bmatrix}
=
\begin{bmatrix} t\_{11} & t\_{21} & t\_{31} & t\_{41} \\ t\_{12} & t\_{22} & t\_{32} & t\_{42} \\ t\_{13} & t\_{23} & t\_{33} & t\_{43} \\ t\_{14} & t\_{24} & t\_{34} & t\_{44} \end{bmatrix}
\cdot
\begin{bmatrix} x \\ y \\ z \\ 1 \end{bmatrix}
$$

which is not that hard anymore.

$$
\begin{bmatrix} 2 \\ 2.5y + 0.5z \\ 3(x + y) \\ x + y \end{bmatrix}
=
\begin{bmatrix} 0 & 0 & 0 & 2 \\ 0 & 2.5 & 0.5 & 0 \\ 3 & 3 & 0 & 0 \\ 1 & 1 & 0 & 0 \end{bmatrix}
\cdot
\begin{bmatrix} x \\ y \\ z \\ 1 \end{bmatrix}
$$

---

## TL;DR

* Remember the advantage of homogenous coordinates $w$.
* $[x, y, z, w] = [n\cdot x, n\cdot y, n\cdot z, n\cdot w]$ is the key.
* Push everything that's in the denominator to the $w$ coordinate.

> **Comments:**
> **username_4**: The original vector is  $(2/(x+y),(5y+z)/(2x+2y),3)$ while your expansion assumes  $(2/(x+y),5(y+z)/(2x+2y),3)$  
> **username_3**: @username_4 Thanks for your comment. I corrected my mistake.  

---

### Answer by username_4 on 2015-10-09. Score: 2

The hint is to use the perspective divide inherent in homegeneous coordinate. So the resulting point you are looking for is $(2, (5y+z)/2, 3x+3y, x+y)$

That matrix then ends up as

$$
\begin{bmatrix}
0 & 0 & 0 & 2 \\
0 & 2.5& 0.5& 0 \\
3 & 3 & 0 & 0 \\
1 & 1 & 0 & 0 \\
\end{bmatrix}
$$

> **Comments:**
> **username_3**: While this answers the question, instead of simply providing the solution to the specific problem it would be much better to describe how the OP could come up with this solution on his own. The question clearly is a homework related question. As of now, this answer does not help to solve the problem with different numbers.  
> **username_0**: Thank you. I just investigated what "perspective divide" is and I found it has to do with finding a w for (x, y, z) in order to get (x, y, z, w). After finding such a value then everything is straight forward. Is this correct? Also, the issue here is to get rid of the variables in denominator.  
> **username_0**: I wonder if I can ask another question related to this same problem. "Assume you have performed the projection on the canonical view volume.  Give the matrix you would use to make the final image of size 5 units wide and 3 units tall." I think the answer is [5, 0, 0, 0][0, 3, 0, 0][0, 0, 1, 0][0, 0, 0, 1] Am I correct?  
> **username_5**: @username_0 i guess you should update the original question. Please explain this topic or link useful resources. I am interested  
> **username_2**: @username_0 if it's a different question but relating to this one then you can post it separately as a new question but include a link to this question.  

---

### Answer by username_6 on 2015-11-04. Score: 1

In homogeneous coordinates i would do something like this:

$$\vec{p} = \left(\frac{2}{x+y}, \frac{5y + z}{2x + 2y}, 3\right)^T = \left(\frac{2}{x+y}, \frac{\frac{5y + z}{2}}{x + y}, \frac{3x + 3y}{x + y}\right)^T$$ adding the fourth coordinate

$$\vec{p}^H = \left(2, \frac{5y + z}{2}, 3x + 3y, x + y\right)^T =
\begin{pmatrix}
0 & 0 & 0 & 2 \\
0 & \frac{5}{2} & \frac{1}{2} & 0 \\
3 & 3 & 0 & 0 \\
1 & 1 & 0 & 0
\end{pmatrix} \cdot \begin{pmatrix}x \\ y \\ z \\ 1\end{pmatrix}$$,

If you want a systematic way, since a linear transformation is completely characterized from the transformation of a basis, take the canonical bases i.e.
($\vec{e}^H\_0 = (1,0,0,0), \vec{e}^H\_1 = (0,1,0,0),...$) apply the transformation in $\vec{p}^H$ it will give you for $i = 0,...,3$ the columns of the matrix.


---

