0
\$\begingroup\$

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

\$\endgroup\$
  • \$\begingroup\$ 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. \$\endgroup\$ – Nathan Reed Apr 17 '14 at 20:09
  • \$\begingroup\$ 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. \$\endgroup\$ – omega Apr 17 '14 at 20:14
  • \$\begingroup\$ @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. \$\endgroup\$ – MichaelHouse Apr 22 '14 at 14:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.