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

I know this is probably an easy problem, but I can't, for the life of me, figure it out. My problem is slightly hard to explain with words alone, so a picture can be found here.

Point $a = (0, 0)$, point $b = (0, 1)$, point $c = (1, 1)$, and point $d = (1, 0)$.

What I want to be able to do is to calculate four percentages (percent $a$, percent $b$, etc), each percent corresponding to its point. If a percent is at $100\%$, then point P is at the point for that percent. i.e., percent $a = 100\%$ when $P = (0, 0)$. Another example would be if point $P$ was directly in the middle of the square at $(0.5, 0.5)$. All the percents would then be at $25\%$.

share|cite|improve this question
You'll need to be clearer about what you are taking the "percent" of. Is the percent based somehow on the distance of between $P$ and the four corners? If so, what are the percentages of the other three corners when $a = 100%$, since point $c$ is actually further away from $P$ in that instance than is $b$ or $d$, yet I'm guessing that you want them each to be equal to $0%$. – cheepychappy Dec 2 '12 at 4:40
up vote 2 down vote accepted

If I'm understanding correctly, i.e. the sum of these percentages should always be 100, I think a formula for these percentages would be as follows. Suppose $P=(x,y)$ with $0\leq x\leq 1$ and $0\leq y\leq 1$. Then, we would have

$$ \begin{align*} a&=100(1-x)(1-y)\\ b&=100x(1-y)\\ c&=100xy\\ d&=100y(1-x) \end{align*} $$

Then, as you can easily check, $a+b+c+d=100$, and when $(x,y)=(0,0)$ we have $a=100$ and $b=c=d=0$, when $(x,y)=(.5,.5)$ we have $a=b=c=d=25$, when $(x,y)=(1,1)$ we have $c=100$ and $a=b=d=0$...and so forth.

share|cite|improve this answer
Simple and effective. Solves my problem perfectly, thanks. – LucasS Dec 2 '12 at 4:49

A simple way to do what you want would be by using barycentric coordinates.

One problem that you may be running into is that you're trying to find some way of specifying a point in the plane as a combination of four different points. In fact, three are enough -- this is why the article I linked to talks about barycentric coordinates in the context of a triangle instead of a square. What this means is that you'll always be able to find some such expression, but it won't be unique. For example, your point at the middle of the square could be described as $25\%$ of each corner, or it could be $50\%$ $a$ and $50\%$ $c$, or any number of other things in between. If you want a unique representation for each point, you'll have to impose some other condition.

If you have the coordinates of some point $P=(x_0,y_0)$, you can find how to write it as a combination of your four points by solving a system of linear equations. Let's say we want the fraction of $a$ in your point to be $P_a$, and similarly with $b,c,d$. Then the equations we get are:

$$P_a+P_b+P_c+P_d=1$$ (that is, the sum of all your proportions should add up to $1$ or $100\%$), and $$ x_0=0*P_a+0*P_b+1*P_c+1*P_d \\ y_0=0*P_a+1*P_b+0*P_c+1*P_d $$ (that is, whatever proportion you're combining $a,b,c,d$ in to get $P$, you should combine the $x$-coordinates of $a,b,c,d$ in to get $P$'s $x$-coordinate, and similarly with $y$-coordinates).

Any numbers $P_a,P_b,P_c,P_d$ which satisfy these three equations will give you a set of viable proportions in which you can combine the points $a,b,c,d$ to get the point $P$. There are only three equations, and four variables $P_a,P_b,P_c,P_d$ to solve for; this is the source of the non-uniqueness problem I was talking about.

share|cite|improve this answer

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.