I am trying to figure out direction vectors of the
arrowheads of an arrow. Basically I'm given a normalized direction vector
(u,v,w) and I need the normalized direction vectors of the its two arrow heads which make a 15 degree angle.
My plan is to first start off with a simple normalized vector
(0,0,1). The direction vectors of its arrow heads are
(-sin(15), 0, -cos(15)) and
(sin(15), 0, -cos(15)), and then rotate
(0,0,1) so its parallel to the given
(u,v,w). I do this by projecting
(u,v,w) on its x-axis, and getting its angle relative to
(0,0,1), then projecting on the y-axis, and getting its angle relative to
(0,0,1), then I use the 3d rotation matrices to use those found angles to rotate the arrow head direction vector.
I have this
pythoncode below, but its not working properly. Does anyone see whats wrong?
ra = math.radians(15) ca = math.cos(ra) sa = math.sin(ra) px = (0,v,w) if u!=1: px = [i/float(math.sqrt(v**2 + w**2)) for i in px] py = (u,0,w) if v!=1: py = [i/float(math.sqrt(u**2 + w**2)) for i in py] pxangle = math.acos(px) pyangle = math.acos(py) cpx = math.cos(pxangle) spx = math.sin(pxangle) cpy = math.cos(pyangle) spy = math.sin(pyangle) def rotatefunction(ah): xr = (ah, -spx*ah, cpx*ah) return (cpy*xr+spy*xr, xr, -spy*xr+cpy*xr) lah = rotatefunction((-sa, 0, -ca)) rah = rotatefunction((sa, 0, -ca))