# Orthogonal vector in two dimensions

Maybe this is really basic, but I couldn't figure it out.

I would like to find the "hat vector" of a vector I defined: it's a vector orthogonal to the given one, assuming two dimensions. So for instance if I create a vector a = {1, 2}, I would like to use some function which gives {-2, 1} as the output.

• I think it's OK to leave this as a valid question - but only after changing the wording to clarify what "hat vector" means here. – Jens Sep 27 '14 at 19:13

It's already built-in. It's called Cross.
Cross[{1, 2}]

foo[v_]:= ({a, b} /. Solve[{a, b} . v = 0, {a, b}])[[1]]