# Finding 3D position between two 3D nodes

This topic is 786 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

This is a pretty basic math question but I'm having trouble with it. Say I have two 3D nodes, n1 and n2, represented by 3D position vectors. How can I find a new position n3 that's between n1 and n2, specified as some distance m from n1?

In 2D space I think this would be

Θ = tan(n2.y - n1.y / n2.x - n1.x)
n3 = [m cos Θ, m sin Θ]

In 3D space I believe we need two of the euler angles but I'm not sure which ones or what to do with them.

(If it makes a difference I'm working with iOS SceneKit.)

Thanks!

##### Share on other sites
n3 = n1+(n2-n1)*m;  (where m is between 0-1)

alternativly if you have a set distance that isn't in 0-1 range.

dis = n2-n1;

alpha = dis/m;

n3 = n1+dis*alpha;

##### Share on other sites

n3 = n1 + specified_distance * (n2 - n1) / length(n2 - n1)

##### Share on other sites

Alvaro, your formula works great. Thanks!

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 11
• 15
• 21
• 26
• 11