Finding the tightest (smallest) triangle that fits all points

73 Views Asked by At

I'm supposed to find an algorithm that, given a bunch of points on the Euclidean plane, I have to return the tightest (smallest) origin centered upright equilateral triangle that fits all the given points inside of it, in a way that if I input some random new point, the algorithm will return $+$ if the point is inside the triangle and $-$ if not. enter image description here

Someone has suggested me to go over all the possible points and finding the point with the largest Eucledean distance from the origin, then, say the point is $(x_1,x_2)$, I should calculate the following:

$(x_1,x_2)⋅(\frac{\sqrt{3}}{2},-\frac{1}{2})=x_{1}\cdot\frac{\sqrt{3}}{2}+x_{2}\cdot-\frac{1}{2}=r_{1}$

$(x_1,x_2)⋅(-\frac{\sqrt{3}}{2},-\frac{1}{2})=x_{1}\cdot-\frac{\sqrt{3}}{2}+x_{2}\cdot-\frac{1}{2}=r_{2}$

$(x_1,x_2)⋅(0,1)=x_{1}\cdot0+x_{2}\cdot1=r_{3}$

Then take the maximum of $r_1,r_2,r_3$, denote it $r_{max}$ and given a new random point $(y_1,y_2)$ output $+$ if

$(y_1,y_2)⋅(\frac{\sqrt{3}}{2},-\frac{1}{2})\le r_{max}$

$(y_1,y_2)⋅(\frac{\sqrt{3}}{2},-\frac{1}{2})\le r_{max}$

$(y_1,y_2)⋅(0,1)\le r_{max}$

It should look something like this:

and output this triangle:

enter image description here

Now when I try to graph points with the same Eucledean distance on a graph, they do indeed seem to be on the sides of the same origin centered upright equilateral triangle, but I can get different $r$ values for different points which have the same Euclidean distance, so I'm quiet baffled as to how it is supposed to work, if this method even works..