Reputation: 267
If I have some objects (images) on a page and I know the coordinates of them, how do I calculate the distance from the top-left corner?
Upvotes: 2
Views: 524
Reputation: 7417
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))
.
Upvotes: 3
Reputation: 3587
Is this any different than
In pseudo-code:
dx = xposition - xcorner
dy = yposition - ycorner
distance = sqrt((dx*dx ) + ( dy*dy))
Upvotes: 5