Reputation: 2623
It seems I am bad at vectors and math or forgot my entire university studies...
I have A, B, C points coordinates (X, Y, Z) where Z = 0.
C is placed in a half distance between A, B points.
D, E points are in parallel to A,B line
Any idea how to find D and E positions with three.js?
A, B, C are Vector3 three.js objects.
Any help is appreciated.
Upvotes: 2
Views: 101
Reputation: 4495
If C is at half the distance between A and B, offset orthogonally, as your figure seems to indicate, then it is simple:
D = C - 0.5AB and
E = C + 0.5AB,
where AB is the vector from A to B.
In THREE.js, you could write it for example like this:
const abHalf = b.clone().sub(a).multiplyScalar(0.5);
const d = c.clone().sub(abHalf);
const e = c.clone().add(abHalf);
though as usual when working with vectors, there are many other ways to calculate it; you may pick your favourite approach.
Is this what you meant?
Upvotes: 1