alin19 Posted January 22, 2008 Share Posted January 22, 2008 for ($j=1; $j<$100;$j+=0.01) { $z=470-2*$j; $x=50+$j; imagesetpixel($img,$x, $z,$black); } i have this script to draw a line from one point with a known lenght; but how can i drow a line between point a(10;20) and b(30;50) just an example please Quote Link to comment https://forums.phpfreaks.com/topic/87259-line-between-two-points/ Share on other sites More sharing options...
Psycho Posted January 22, 2008 Share Posted January 22, 2008 Well, you could try to incorporate some geometry to find the equation of the line (Y= MX + B). But, that would make the solution rather complex. Here is the approach I would take. You know that the line was a width (X) of 20 units. And in that space the height (Y) changes 30 units. So, the slope if the line would be 30/20 or 1.5. So for any X position, the Y position would be 20 + (1.5 * (X-10)) Where 20 is the starting Y position and 10 is the starting X position. So, just create a loop to iterate through each X coordinate and compute the Y coordinate. Quote Link to comment https://forums.phpfreaks.com/topic/87259-line-between-two-points/#findComment-446351 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.