3
$\begingroup$

I had a hard time finding a good title for this. Feel free to edit it if you find something more appropiate.

What I'm trying to do is finding a function such that, given a point $C$ (center), gives the square-wise distance from any point to $C$.

Now, for a simple definition of square-wise dist, imagine a square of a fixed size centered at $C$ and aligned to the $x$ and $y$ axis. I want each point of this square to be at the same square-wise distance from $C$, so it's the same as euclidean distance but changing circle by square.

How would I go into computing that? I can't wrap my head around it...

$\endgroup$
5
  • 1
    $\begingroup$ Hint: Consider each of the x-coordinate and the y-coordinate of the said two points. $\endgroup$ Commented Aug 11, 2014 at 8:44
  • 1
    $\begingroup$ en.wikipedia.org/wiki/Uniform_norm $\endgroup$ Commented Aug 11, 2014 at 8:46
  • 1
    $\begingroup$ @TheGreatSeo: It's taxicab geometry at a 45 degree angle. $\endgroup$ Commented Aug 11, 2014 at 9:00
  • $\begingroup$ @user2357112 It seems to be. I confused. $\endgroup$ Commented Aug 11, 2014 at 9:00
  • $\begingroup$ I'll have a look into that link. I didn't know this had a name! PD: Btw this is all related to a shader I'm writing, so when I get back home I'll edit my question and post a graphical representation of both euclidean distance and this distance with colors, I think that might also help to clearify my question for other readers. $\endgroup$
    – Setzer22
    Commented Aug 11, 2014 at 11:51

2 Answers 2

3
$\begingroup$

If $C = (x_c, y_c)$, and $P = (x,y)$, then: $$d(P,C) = \sup\{|x_c - x|, |y_c - y|\}$$ does the job.

$\endgroup$
3
  • $\begingroup$ sorry, what's sup? I assume it's the supreme of the set (idk if that's english) i.e. max, right? $\endgroup$
    – Setzer22
    Commented Aug 11, 2014 at 11:46
  • $\begingroup$ That's right (: $\endgroup$
    – Ivo Terek
    Commented Aug 11, 2014 at 11:47
  • $\begingroup$ Nice, thanks! Then that does the job. I just came to that thinking: Well, if the point lies whithin a square's perimeter the largest of the x and y coordinates must be the side of the square. Then I saw your answer, so it makes sense. $\endgroup$
    – Setzer22
    Commented Aug 11, 2014 at 11:50
2
$\begingroup$

You may like the following :

$$|(x-a)-(y-b)|+|(x-a)+(y-b)|=A$$ represents a square whose edge length is $A$ with the center $(a,b)$.

For example, see here.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .