Returning each co-ord between two points of a linear line

boo1234
Messages
1
Reaction score
0
Hi,

I need to come up with an equation/solution/way to return each of the co-ordinates between two points in a line.

This is for a game, I want to return the co-ords between two player locations.

Let's say for example player one is at 20,5 and player two is at 41,5

I need to return:

21,5
22,5
23,5
24,5
25,5

and so on up to 41,5

The points are dynamic

Help appreciated.

To clarify I need to return each TILE that the 'line' passes through between two players.
 
Physics news on Phys.org
Well you can just take x_2-x_1 that gives you the distance x_2 to x_1 let's call it a, then do the same for y and call it b, now simply add one to each co-ordinate or take one if a or b are negative to x_1 and y_1 respectively until a=x_2-x_1 or until b=y_2-y_1. If a and b respectively are equal to x_2-x_1 and y_2-y_1 then stop. Should provide you with each co-ordinate between the two points. Being a computer I'm sure it can update that in real time with no problems.
 
Last edited:
Prove $$\int\limits_0^{\sqrt2/4}\frac{1}{\sqrt{x-x^2}}\arcsin\sqrt{\frac{(x-1)\left(x-1+x\sqrt{9-16x}\right)}{1-2x}} \, \mathrm dx = \frac{\pi^2}{8}.$$ Let $$I = \int\limits_0^{\sqrt 2 / 4}\frac{1}{\sqrt{x-x^2}}\arcsin\sqrt{\frac{(x-1)\left(x-1+x\sqrt{9-16x}\right)}{1-2x}} \, \mathrm dx. \tag{1}$$ The representation integral of ##\arcsin## is $$\arcsin u = \int\limits_{0}^{1} \frac{\mathrm dt}{\sqrt{1-t^2}}, \qquad 0 \leqslant u \leqslant 1.$$ Plugging identity above into ##(1)## with ##u...
Back
Top