Hi @Pryme8 I have just seen that you posted the answer while I was typing this dissertation.
A little of the basics first
A vector is an object with direction and and length. In this image all examples of a are the same vector, this is also true of b and c.
Given a fixed origin vectors can be used to fix a point in space, any vectors starting from O are called position vectors. In Figs 1 and 2 O is a fixed origin. In Fig 1, a, b and c are position vectors, in Fig 2 only a and b are position vectors.
If you look at the two triangles you can get from the starting point of c to the end point of c by going backwards along a and then along b. We can write
c = b - a and it follows
b = c + a as you can see in this picture
In Babylon.js when A, B and C are Vector2s, Vector3s or Vector4s with
C = B.subtract(A)
then B = C.add(A)
When start and end are two position vectors and you travel from start to end then
end = start + direction just follow the arrows
In Babylon.js
end = start.add(direction)
You can find the length of the direction vector with direction.length()
.
A unit vector u is one that has length 1, and by multiplying by a scalar p you get a vector in the same direction of length p
When you know a direction vector in Babylon.js you get a unit vector by
direction.normalize()
this changes the direction vector to a unit vector and so direction.length()
with now be 1.
For any end point change the value of P in
end = start.add(direction.scale(P));
Do not know the book you included in the post. You can learn a lot about vectors from the web, including Wikipedia.