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

• boo1234
In summary, the conversation discusses the need to create an equation or solution for returning the coordinates between two points in a line for a game. The points are dynamic and the goal is to return each tile that the line passes through. One suggestion is to calculate the distance between the two points and then add or subtract one from each coordinate until the distance is reached. This process can be updated in real time without any issues.
boo1234
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.

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:

## 1. What is a linear line in mathematics?

A linear line is a straight line that follows the equation y = mx + b, where m is the slope of the line and b is the y-intercept. It can also be described as a set of points that have a constant rate of change.

## 2. How do you calculate the slope of a linear line?

The slope of a linear line can be calculated by finding the change in y values over the change in x values between two points on the line. This can be represented by the formula (y2 - y1) / (x2 - x1).

## 3. What is the significance of returning each co-ordinate between two points of a linear line?

Returning each co-ordinate between two points on a linear line allows you to plot all the points on the line and visualize its overall shape and direction. It also helps in calculating the slope of the line and determining its equation.

## 4. How do you find the equation of a linear line?

The equation of a linear line can be found using the slope-intercept form, y = mx + b, where m is the slope of the line and b is the y-intercept. You can also find the equation by using two points on the line and plugging them into the slope formula, (y2 - y1) / (x2 - x1).

## 5. Can a linear line have a negative slope?

Yes, a linear line can have a negative slope. This means that the line is decreasing from left to right and has a downward direction. A negative slope can also be represented as a negative value for m in the slope-intercept form, y = mx + b.

• Calculus and Beyond Homework Help
Replies
5
Views
2K
• Calculus and Beyond Homework Help
Replies
2
Views
4K
• Calculus and Beyond Homework Help
Replies
1
Views
947
• Calculus and Beyond Homework Help
Replies
2
Views
1K
• Calculus and Beyond Homework Help
Replies
1
Views
1K
• Calculus and Beyond Homework Help
Replies
2
Views
1K
• General Math
Replies
10
Views
2K
• General Math
Replies
13
Views
1K
• Aerospace Engineering
Replies
0
Views
544
• Set Theory, Logic, Probability, Statistics
Replies
2
Views
1K