How to Translate and Rotate axes to match a vector

Hello All,

I am trying to draw an arrow to represent a vector. I have two points with (x,y,z) coordinates of the vector. I have been searching the forums to draw an arrow which suggest the best way is to draw using three lines.
Now coming to my problem, I can draw the main arrow line joining the two coordinates I have, but drawing the two small lines at the tip is challenging.
The idea I settled down with is translating and rotating the axes to match the vector as one of the axes. I can calculate the angle but without the sign of the angle, so not sure in which direction I need to rotate.
Any suggestions as to how can I do this?! My ultimate goal is to draw an arrow along the vector as a representation. Is translation & rotation a good idea or is there a better way to achieve this?

Thanks in advance

I find scaling, translating, and rotating to be an easy way to do what you’re trying to do. Write a subroutine that makes a 3D arrow, one unit long, going down the X axis, with it’s tail at the origin, and it’s tip at (1,0,0). You can use gluCylinder twice to do that - once for the shaft and once for the tip. Then scale, rotate, and translate that arrow to go between your 2 points.

Thank you MaxH.
I am trying to reproduce your solution, will post back once done.

I did work out, but had to do some complicated math to calculate the angle of rotation.
Also there are some sites offerring ready-written code for rendering a cylinder given two points (coordinates of two points). Created the code myself, also planning to try the codes available on web to cross-check mine.
Thank you for all the help

You have to do some trig or some vector operations. It’s good that you worked it out for yourself.