How can I draw an arrow between 2 points?

Hi,

I would like to draw an arrow aligned with two points.

How can I do this?

I have tried drawing a cylinder and then a cone using GLUT, but I am not sure how to get the right rotation.

How can I calculate the right rotation for the arrow to point from the first to the second point?

Thanks!!!

Hello,

One “simple” way is to just use “change of basis”. First, you build your arrow in the “standard” basis (where X axis = (1, 0, 0) and Y axis = (0, 1, 0) and Z = (0, 0, 1) since it is the simplest). Then, to make it point some where else, just redefine the basis to “make” it point where you want.

Since your cone and cylinder look the same no matter how it is twisted, the only important part of the basis is the vector that is parallel to the arrow (the pointing direction). The other two vectors can be anything so long as they still make an orthogonal basis.

Check out http://pages.cpsc.ucalgary.ca/~hassana/change_basis/change_basis.png

Hope that helps.

PS: Let me know if the math doesn’t make sense or if you find errors, thanks.

Thanks hky!

The leap from your mathematics to code was a little long for me, but I found another example with sourcecode at http://www.mfcogl.com/OpenGL%20-%20draw%20cylinder%20between%202%20pts.htm which worked for me!

Thank you anyway for trying to help - I really appreciate it :slight_smile: