In one of the algorithms I encountered an formula to calculate a scalar number from 2 points. Given Point 1 has coordinates $(x1,y1)$ and Point 2 has coordinates $(x2, y2)$ the formula was following

$\sqrt{(y1-x1)^2 + (y2-x2)^2}$

If the $x1$ is equal to $y1$ and $x2$ is equal to $y2$ then the result is $0$. On the other hand the result grows when coordinates are far from the diagonal.

Does this formula has any name or does it serve any well known purpose e.g. in gaming?

  • $\begingroup$ Pythagorean theorem $\endgroup$
    – caverac
    Jan 10, 2019 at 21:25
  • $\begingroup$ Nope. Check the coordinates.... Oh, and this has nothing to do with "scalar product." $\endgroup$ Jan 10, 2019 at 21:26
  • $\begingroup$ @caverac But Pytagorean hypothenuse whould be $\sqrt{(x1-x2)^2+(y1-y2)^2}$ $\endgroup$
    – nan
    Jan 10, 2019 at 21:36
  • $\begingroup$ You're right, I misread the variables. Are you sure this is the right expression? $\endgroup$
    – caverac
    Jan 10, 2019 at 23:51
  • $\begingroup$ Some context for this expression would be helpful. $\endgroup$
    – amd
    Jan 11, 2019 at 0:50


You must log in to answer this question.

Browse other questions tagged .