Apologies for any wording and incorrect references, 3 dimensional maths is new to me!
Problem:
- I have two points in 3D space A:
(1,2,3)and B:(6,5,4) - I have a distance L: 10
- What is the 3D point C as defined as A TOWARDS B at a UNIT of L?
Notes:
- Distance of L is not a factor of the distance between A or B, there
.lerp()is not the right tool here - L can be both greater and smaller than the distance between A and B.
I'm using THREE.js, but any language examples are welcome!
Workings so far:
- Calculate distance between A & B -> D
- Get factor of D in relation to our target value L -> R
- Apply .lerp() with A towards B with factor R
function lerpUnit (x1,y1,z1,x2,y2,z3,distance) {
... ???
return {x3,y3,z3}
}