Find vector closest to X_AXIS
-
With a given set of various vectors, how do you determine which one is the one most parallel to another, say the
X_AXIS? -
take the dot product of each vector, normalized, with the vector you are comparing against, normalized.
how_close = vector_a.normalize().dot( comparison_axis ) how_close_b = vector_b.normalize().dot( comparison_axis )the normalize is important because they all need to be the same length for this kind of comparison.
-
Does the direction of the vector matter then?
-
Oops sorry. Meant to tack that on.
dot product = 1 means parallel and in the same direction
dot product = -1 means parallel and in the opposite direction.So if direction matters, look for closest to 1. If it doesn't, use the absolute value.
-
Great! Thank you very much!

Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement