Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

assume we have 3 vertices and a point inside the triangle.

with a homography matrix




Also the final location of the 3 vertices and the point that is not inside the triangle anymore.

how to find out this homography matrix? you are free to set the vertices to any location.

The one I thought is after transformation, the triangle becomes a single line, all points lie on this line.

However, the matrix I found is not invertible. anyone please help?

share|cite|improve this question
It is not clear what you are asking for. Do you just want a homography that takes the point inside the triangle to a point outside the triangle, with no restriction on the images of the other points? – Mårten W Feb 7 '13 at 8:41
@MårtenW yes, just a homography that takes a point inside the triangle to outside, no restriction. – fiftyplus Feb 7 '13 at 16:59
up vote 0 down vote accepted

Suppose we have the four points $p_1,p_2,p_3,p_4$ with homogeneous coordinates $$ p_1=\begin{bmatrix}-1 \\ 0 \\ 1\end{bmatrix}, \quad p_2=\begin{bmatrix}1 \\ 0 \\ 1\end{bmatrix}, \quad p_3=\begin{bmatrix}0 \\ 2 \\ 1\end{bmatrix}, \quad p_4=\begin{bmatrix}0 \\ 1 \\ 1\end{bmatrix}, $$ and we want to map $p_1,p_2,p_3$ to themselves but $p_4$ should be mapped to $$q=\begin{bmatrix}0 \\ -1 \\ 1\end{bmatrix}.$$

This results in a linear equation system of the form $$ \left\{ \begin{array}{rcl} Hp_1 & = & \lambda_1 p_1\\ Hp_2 & = & \lambda_2 p_2 \\ Hp_3 & = & \lambda_3 p_3 \\ Hp_4 & = & \lambda_4 q \end{array} \right., $$ in which there are twelve unknowns (eight from $H$ and four $\lambda_i$) and twelve equations. Solve this system and get $$H=\frac{1}{3}\begin{bmatrix}3 & 0 & 0 \\ 0 & -1 & 0 \\ 0 & -2 & 3\end{bmatrix}.$$

Note however that you may not in general assume that a given element in $H$ is one just because the scaling is arbitrary, because it may need to be zero.

share|cite|improve this answer
Thanks first, and now I know where is my problem, I don't have the λi. I understand the overall ideas, but why we must have the λi to solve the H? – fiftyplus Feb 7 '13 at 20:50
Recall that the homogeneous coordinates are defined as equivalence classes of three-component vectors. Since we cannot be sure of which representative of the equivalence class we get, we must have the uknown $\lambda_i$ to account for that. – Mårten W Feb 7 '13 at 20:54
Wait, I just realize that if I try to convert the transformed point back to 2D. should I multiply the λ? If I need to, then the transformed point is still inside the triangle. Please justify. Thanks – fiftyplus Feb 8 '13 at 0:29
@fiftyplus: $p=\begin{bmatrix}x \\ y \\ 1\end{bmatrix}$ and $\lambda p=\begin{bmatrix}\lambda x \\ \lambda y \\ \lambda\end{bmatrix}$ represent the same point (assuming $\lambda \neq 0$), but if you want the cartesian coordinates you must choose the representative with third coordinate equal to one. – Mårten W Feb 8 '13 at 7:44

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.