finding a point on line

Need help with Photoshop, the GIMP, Illustrator, or others? Want to show off your work? Looking for advice on your newest Flash stuff?

Moderator: General Moderators

Post Reply
bugthefixer
Forum Contributor
Posts: 118
Joined: Mon Mar 22, 2004 2:35 am

finding a point on line

Post 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.
User avatar
AVATAr
Forum Regular
Posts: 524
Joined: Tue Jul 16, 2002 4:19 pm
Location: Uruguay -- Montevideo
Contact:

Post 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)
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post 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);
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply