On Thu, 4 Feb 2021, 15:50 Andy Latto, <andy.latto@pobox.com> wrote:
The problem with this is how you define "same direction" in n-dimentional
space. You can't just look at the signs; two vectors may have the same sign in one coordinate and different signs in a second coordinate.
No they can't. I first had written a more detailed description of how to flip the sign but i have discarded it in favour of this simpler wording which is indeed unambiguous. Convince yourself that either all components have the same sign (as the respective component of the other vector) or all have the opposite signs of those of the other vector, when the two vectors are proportional (aka collinear). But FWIW, you can (and should) look just at the sign of the component which has the largest absolute value. (For the components close to zero, accumulated rounding and similar errors could indeed give an incorrect sign, viz –0 ≈ +0. But the sign of the largest components must be significant, unless the whole data has become random noise.) - Maximilian If you flip
one so that they have the same second coordinate, they have different first coordinates.
A slightly more sophisticated approach would be to say that two vectors are in the "same direction" if their dot product is positive, so if their dot product is negative, flip one of them.
But this doesn't work for more than two vectors, because the "same direction" relation is not transitive.
Andy
I have a quite elegant solution and reasonably efficient solution,
but I wanted to see if anyone else had the same idea.
Does the above go in the same direction of your idea, Henry ?
- Maximilian