Line Equation
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.
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!
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!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement