# How can I translate & rotate an object to match a pair of xyz coordinates?

I'm trying to script the modeling of a set of 3D vectors. For a given vector, I have the start and end points in 3D space -- for example from 1,1,1 to 2,2,2. I'm not sure of the best way to approach this problem.

I'm imagining a cylinder with a cone on the end ("arrow") all grouped together that is located in some arbitrary location but with a unit length (e.g., 0,0,0 to 0,0,1). My inclination was parent the arrow to a bone and the translate the bone to the first position, followed by translation of the other end of the bone to the second position. Since the arrow is radially symmetric, rotation won't be an issue.

This solution seemed convoluted to me though (building an armature, etc.), since I have the endpoints where the geometry should go. It seems like there should be a way to translate the central node of the cylinder to point 1 and then translate/rotate the node at the tip of the cone to point 2.

I have read some of the other questions about orienting lights to normals (here, here, here), or rotating planes to be normal to a point, so I think the solution might be along those lines.

If you don't like the choice of X as the primary axis, you can rearrange the arguments to Matrix([a2,b2,c2]) , although some of those orderings will be left-handed instead of right-handed, requiring you to reverse one of them. For example Matrix([b2,a2,-c2]).
If you want your cylinder to stretch with the distance between the points, you can use non-normalized a instead of a2.