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.
finding a point on line
Moderator: General Moderators
-
- Forum Contributor
- Posts: 118
- Joined: Mon Mar 22, 2004 2:35 am
- AVATAr
- Forum Regular
- Posts: 524
- Joined: Tue Jul 16, 2002 4:19 pm
- Location: Uruguay -- Montevideo
- Contact:
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)
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);
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.