0
$\begingroup$

I got a couple of diamond put side by side like on the image below

diamond coordinates

The only coordinates I know on the image are the top corners (green text).
I need to know which diamond does a dot belong.
Example: for the red dot, how do I know that x:260, y:179 = the top diamond ?
And the blue belongs to the left ? etc...

Just a precision, the diamonds are a bit squashed (not like on the picture) if I do a rotation I'll get a parallelogram.

Thank you very much for your help.

1 Answers 1

3

The line $L_1$ from $\langle 113,114\rangle$ through $\langle 225,227\rangle$ has the equation $y-114=\frac{227-114}{225-113}(x-113)=\frac{113}{112}(x-113)\;,$ or $y=\frac1{112}(113x-1)\;.\tag{1}$ The line $L_2$ from $\langle 337,114\rangle$ through $\langle 225,227\rangle$ has the equation $y-114=\frac{227-114}{225-337}(x-337)=\frac{113}{112}(337-x)=\frac1{112}(38081-113x)\;,$ or $y=\frac1{112}(50849-113x)\;.\tag{2}$

To determine where a point $\langle a,b\rangle$ is in the big diamond, substitute $x=a$ into $(1)$ and $(2)$. Let the corresponding $y$ values be $y_1$ and $y_2$. Compare $y_1$ and $y_2$ with $b$. If $b, your point is above $L_1$; if $b=y_1$, your point is on $L_1$; and if $b>y_1$, your point is below $L_1$. Similarly, if $b, your point is above $L_2$; if $b=y_2$, your point is on $L_2$; and if $b>y_2$, your point is below $L_2$. From that information you can easily determine the small diamond in which your point lies.

For example, for the red point we have $a=260$ and $b=179$. Substituting $x=260$ into $(1)$ and $(2)$, we find that $y_1=262.3125>179$, so the red point is above $L_1$, and $y_2=191.6875>179$, so the red point is also above $L_2$. In other words, it must be in the top small diamond.

By the way, your dividing lines aren’t quite parallel to the upper edges of the big diamond: if they were, they’d meet at $\langle 225,226\rangle$. I don’t know whether this is intentional, or whether it matters to you.