Find Right Angle to a Vector

BlitzMax Forums/BlitzMax Programming/Find Right Angle to a Vector

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

The simple way to get a perpendicular vector is to remember that the dot product must be zero.

Starting with vector (x,y) you just swap the two numbers and make one of them negative.
One possible result is (y,-x). The dot product with (x,y) is

x*y + y*(-x) = x*y - x*y = 0.

So (y,-x) is perpendicular to (x,y).

Of course, (-y,x) works as well. Which is a right turn and which is left depends on the coordinate system used. Just try them both and see what they do.