# How to find optimal perpendicular axis of rotation vector to draw arrows?

I am drawing lines on the screen. Each line has a point (x,y,z) and a direction (u,v,w). I want to draw arrow heads on these lines, like two lines that start from (x,y,z) and leave at a 15 degree angle.

I know how to draw these arrow head lines. I do this by rotating (u,v,w) by 15 degrees on some axis of rotation which is perpendicular to (u,v,w). The problem is the axis of rotation I am using is not making all my graphs look good.

Basically I'm given a unit vector (u,v,w). If |w|=1, then u and v are 0 and I just use (1,0,0) which is a unit vector and perpendicular to (u,v,w).

If that is not the case, then I use (v, -u, 0) which is not a unit vector but is perpendicular. Then I normalize it. The norm won't be 0, since |w| < 1 which means u^2 + v^2 != 0.

This gives ok results. But some tests, the arrow head lines look a bit messed up, or not even looking like a 15 degree angle from the main line.

Does anyone know a good way to find a good perpendicular unit vector to (u,v,w) so the results will always look good?

Thanks

• Can you add some screenshots of cases where the arrows look "messed up", and clarify what you mean by "the results will look good"? There are many ways to find a vector perpendicular to (u,v,w) but it's impossible to say what will "look good" in your situation, unless we know more about what you're looking for. – Nathan Reed Apr 17 '14 at 20:09
• Actually I think i figured out the problem, its cause the z-axis height is not a 1:1 ratio with the x-axis/y-axis. Ex. the x-axis/y-axis is like from 0 to 10, and the z-axis is from -20 to 70. So its making the arrows look weird. But I think my math is right. – omega Apr 17 '14 at 20:14
• @omega You should update the question with your new findings and screenshots. Remember that "looks good" and "messed up" are subjective terms that should be defined. Images can help with that. – MichaelHouse Apr 22 '14 at 14:13