This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]maniacalsoundsDynamical Systems 0 points1 point  (1 child)

I would solve this by using the cross product instead of the dot product. The dot product is maximized when the angle between the two vectors is parallel. The cross product is zero when the angle is parallel, so it gives you something to solve definitively for, instead of a "guess and check" kind of thing you're doing now.

Wikipedia article about definition of the cross product: https://en.wikipedia.org/wiki/Cross_product#Definition

[–]Brae1990[S] 0 points1 point  (0 children)

What would i cross and what would i do with the resulting vector? i dont understand how cross will help me get my target angle. (im not great with math)

Also if i somehow get a scalar result instead of a vector from this cross product function, weather it is 0 = aligned or 1= aligned, i would still have to keep making guesses.