Take the 2-minute tour ×

Doing some 3D stuff in wpf- want to use a simpler test to see if everything is working (before moving to curves).

The basic question is given two points x1,y1,z1 and x2,y2,z2 I have calculated the distance between the points. But how to find the coordinates of another point (x3,y3,z3) that lies on that line at some distance?

I.e. if my line is 100 long between -50,0,0 and 50,0,0 what are the coordinates of the point at 100 * 0.1 along the line?

I think this is a simple formula but I haven't found it yet....

share|improve this question

4 Answers 4

up vote 9 down vote accepted

For each p between 0 and 1 then this will give you a point on the line segment:

(x1, y1, z1) + p * ((x2, y2, z2) - (x1, y1, z1))
share|improve this answer
+1. In the example the questioner has given simply let p=0.1 and this translate nicely. Good job keeping it simple. –  Platinum Azure May 21 '10 at 22:59
This was also very useful! So to solve for each of my points I did: x3 = x1 + p(x2-x1). Repeat for y and z. –  Nicros May 22 '10 at 0:02

This has to do with math, but ok. Let P and Q be the two given points and X the point you're looking for.

P + r(P-Q) = X

r indicates a factor.

if 0 < r < 1: the point x will be on the line between the two points.

That's it!


To find a point at a given distance d from P(p1/p2/p3):

d² / euclidian_square_distance(P,Q) = r

Insert r in the equation mentioned above and you'll have your point! :)

P.S: Btw: P-Q = (Px - Qx, Py - Qy, Pz - Qz)... i bet you alread knew it :)

share|improve this answer
This was very helpful! –  Nicros May 21 '10 at 23:52

Let t vary from 0 to 1. Use the following:

(x3, y3, z3) = (1-t)*(x1, y1, z1) + t*(x2, y2, z2)

When t=0 you get the first point. When t=1 you get the second.

This method is called linear interpolation.

share|improve this answer

a line joining the points in 3d is given by equation:

(x - x1)/(x2 - x1) = (y - y1)/(y2 - y1) = (z - z1)/(z2 - z1)

You have the values of x1,y1,z1,x2,y2,z2. This will give you an equation for the line.

another equation would be


Solve the 2 equations to get the value of the points.

share|improve this answer

Your Answer


