Hey. This is nothing fancy and im sure people can write their own fine - but for a game im working on I needed to be able to trace a certain amount of steps down a line and return the x,y of that point.
Heres the function I wrote to do it, should work with any line at any angle regardless of co-ordinate positions. Dunno what will happen if you ask to get a point further down the line than the length of the line though
Function GetPointInLine(X1, Y1, X2, Y2, Steps, Axis)
DistX = X2 - X1
DistY = Y2 - Y1
Angle = AtanFull(DistX, DistY)
If Axis = 0
Result = X1 + Steps * Sin(Angle)
Else
Result = Y1 + Steps * Cos(Angle)
Endif
EndFunction Result
axis 0 is return the X co-ordinate, axis 1 is return the Y. Steps is simply how far down the line (like 5 would return the point 5 pixels down the line)
Maybe someone will find it usful ^^
p4 2.4ghz, 768ddr ram, Geforce FX 5200
Innovate, redefine, recreate whats in your mind. It isnt fate, you decide, only you can cross that line.