Hi, I have question and I don’t know how to realize it. Let’s say I have 4 Vector3 and I want to increase each of them on the z-axis by 100 and at the same time keep the angle of these vectors (as in the picture). In other words, I need the vector to be greater along the z-axis by 100 and always parallel to the initial vector. I will be glad for any advice.
I’m not sure I understand the question.
THREE.Vector3is a position vector, thus its coordinates define its size (direction and length) only, and there is no data about where in the plane is the vector – position-vectors are by definition assumed to start from (0,0,0).
Your image features another type of vector, some call it directed segment. It has a beginning and end, thus in Three.js such vectors are represented by two
In Three.js there is a third type of vector, called direction, used for rays and raycasting. It is defined by two THREE.Vector3; the first one is the position of the beginning, and the second one is a unit position vector relative to the beginning.
The answer to your question strongly depends on what type of vector you do mean:
Position vectors can change their Z coordinate and keep the same direction by uniform scaling. For example:
(x,y,z) → (kx,ky,kz), where k = (z+100)/z
Note: This is not available for all vectors, for example, the operation is undefined for (0,0,0); and it will flip the direction for (0,0,-1).
The transformation of directed segments is done by the addition to both THREE.Vector3, thus translating the vector without rotation. For example:
[(x1,y1,z1), (x2,y2,z2)] → [(x1,y1,z1+100), (x2,y2,z2+100)]
Note: This is available for all directed segments.
The transformation of directions is done by the addition to the first THREE.Vector3. For example:
[(x,y,z), (ux,uy,uz)] → [(x,y,z+100), (ux,uy,uz)]
Note: This is available for all directions.