Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Given a line defined as two points in screen coordinate space (which themselves are two 2D vector positions) how would I calculate a 2D Vector perpendicular in the "up" direction for determining a normal force?

share|improve this question
The normal is not consistently defined if what you have is just a pair of (A,B) points. But you can choose one in your 2D plane, e.g. the one pointing at the left w.r.t to your BA vector. – teodron Aug 30 '12 at 11:11
@Casey, check this link for a solution: – boobami Aug 30 '12 at 11:15
up vote 2 down vote accepted

If you have a vector v = A - B (the direction is from B to A), then you need to find a vector u so that dot(u,v) = 0.

If v=(x,y), there's no unique solution for this problem, but let's choose the normal pointing to the left side of the v vector. This one is u=(-y,x) and it is attained by rotating v by 90 degrees. Using complex numbers: v = x + i y and a rotation of 90 degrees means multiplying v by i. Hence u= vi = i x - y or in cartesian coordinates: u=(-y,x).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.