简体   繁体   English

如何计算左上角(0,0)的距离?

[英]How to calculate distance from top left corner (0, 0)?

如果我在页面上有一些对象(图像)并且我知道它们的坐标,我该如何计算左上角的距离?

Is this any different than 这有什么不同吗?

  1. subtracting the X coordinates, squaring the result 减去X坐标,平方结果
  2. subtracting the Y coordinates, squaring the result 减去Y坐标,平方结果
  3. adding the two squares, 添加两个方块,
  4. taking the square root? 拿平方根?

In pseudo-code: 在伪代码中:

dx = xposition - xcorner
dy = yposition - ycorner
distance = sqrt((dx*dx ) + ( dy*dy))

You apply the Pythagorean Theorem from your high school trigonometry class. 你从高中三角学课上应用毕达哥拉斯定理 The distance from, say, (0, 0) to (55, 23) is the square root of ((55 x 55) + (23 x 23)) . (0, 0)(55, 23)距离是((55 x 55) + (23 x 23))平方根。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM