Page 1 of 1

finding a point on line

Posted: Tue Aug 24, 2004 6:31 am
by bugthefixer
i have a line whose starting pointis
(23,56)
and its ending point is
(44,78)

suppose if there are 8 equal division on that line, so now i want to
find the point in terms of (x,y) which is 4 divisions away from start
point.

is there any php function which can do that for me.
or if anybody can tell me any code for doing that.

Posted: Tue Aug 24, 2004 9:03 am
by AVATAr
I think is more a math (algebra?) question than a php one... Search for Euclides.!!!.. (http://www.cut-the-knot.org/triangle/n-parts.shtml)

Posted: Tue Aug 24, 2004 9:54 am
by pickle
This might work.

Code: Select all

//divide the rise and the run by 8,
$rise = 78 - 56;
$run = 44 - 23;
$rise_segment = $rise/8;
$run_segment = $run/8;

$fourth_section_x = 23 + ($run_segment * 4);
$fourth_section_y = 56 + ($rise_segment * 4);