#### Archived

This topic is now archived and is closed to further replies.

# Line Equation

This topic is 5419 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Does anyone know how to calculate the points that make up a line? I know how to test if a point is on the line but i want to be able to build a line and can''t seem to do it without gaps and other abnormalities.

ay + bx + c = 0

##### Share on other sites
Depends how you want to do it
There is
y=mx+b
where m is the slope and b is the y-intercept

or you could go the more graphics oriented approach

Pnew=P0+t(P1-P0)
where P0 is the starting point, P1 is the ending point and t is a value between 0 and 1. If t is 0.5 then the equation gives you a point on the line halfway between the two. t can be greater than 1 or less than 0 if you want an infinite line but in graphics we usually work with line segments.

"Give a man a fish and he will eat for a day, drown a man in the water and the fish will eat for a week!

##### Share on other sites
If you''re wanting to know how to do pixel plotting for the line, the classic alogorithm is Bresenham''s line algorithm. There''s an article describing it here on gamedev.

1. 1
Rutin
42
2. 2
3. 3
4. 4
5. 5

• 9
• 27
• 20
• 14
• 14
• ### Forum Statistics

• Total Topics
633385
• Total Posts
3011600
• ### Who's Online (See full list)

There are no registered users currently online

×