[英]How to calculate distance from top left corner (0, 0)?
如果我在页面上有一些对象(图像)并且我知道它们的坐标,我该如何计算左上角的距离?
Is this any different than 这有什么不同吗?
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.