Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What would be the most efficient (or right..) way to determine edge coordinates of both sides of arrowhead? Picture is worth a thousand words so I'll explain this with one. I know coordinates A and B, and will need coordinates C and D. Side of an arrowhead (S) is 10px and angle a is 0.5 rad.

I have done this with some (very basic) trigonometric functions and with a lot of if-else-statements. I know this can be done more wisely, but my knowledge ends after calculating angle of big arrow and subtracting 0.5 radians from that (that's obviously wrong since it doesn't change phase)

enter image description here

share|cite|improve this question
Have you considered making the head the origin and then performing simple coordinate geometry? – picakhu Sep 27 '11 at 21:27
Or make $AB$ horizontal, with $A$ the origin, compute the coordinates and then rotate them back to the original position. Note that no angles need to be found for this rotation: just send $e_1$ to $AB$ and $e_2$ to $AB^\perp$. – lhf Sep 27 '11 at 21:39
I think @pic has the right idea. Alternatively, you could repharse the same problem as vector addition. Namely, have A to B be a vector, and create a vector each for the left and right edges of the arrow head. Given b, the angle of the body of the arrow from horizontal, the right would be <Scos(b+pi+a) , Ssin(b+pi+a)> and the left <Scos(b+pi-a) , Ssin(b+pi-a)>. C, then is V_AB + V_left and D is V_AB + V_right. – Drew Christianson Sep 27 '11 at 21:47
up vote 1 down vote accepted

The quickest solution I see (and wrote a quick comment to this effect) is to phrase the problem as addition of vectors, rather than trying to directly derive the coordinates from trig functions. I'm assuming you have your choice of methods and coordinate systems.

So, to derive the coordinates of C and D, first let A be the origin. For points $A = (a_1 , a_2) , B = (b_1 , b_2)$, B' is then $(b_1 - a_1 , b_2 - a_2)$ Then, define $$V_{B'}=<b_1 - a_1 , b_2 - a_2>$$. Then the magnitude of the vector is $\sqrt{(b_1 - a_1)^2 + (b_2 - a_2)^2} = M$. $\angle V_{B'}$ (the angle from the horizontal of the body of the arrow) is $arccos(\frac{b_1 - a_1}{M}) = b$ where arccos is the inverse cosine function (NOTE: this assumes the arrow is pointing up and to the left or right). This follows from the definition of a vector given M and b: $$<M cos(b) , M sin(b)>$$

We use that definition, along with S and b for formulate vectors $V_{left}$ & $V_{right}$ for the arrowheads: $$V_{right} = <S *cos(b + \pi - a) , S * sin(b + \pi - a)>$$ $$V_{left}=<S *cos(b+\pi+a),S*sin(b+\pi+a)>$$ Then, Point C $=V_{B} +V_{left}$ and Point D $=V_B + V_{right}$.

share|cite|improve this answer
Thank you so much! That was exactly what I was looking for. With those formulas it worked right out of the box. – Juha Sep 28 '11 at 19:55
You're welcome, glad to help. – Drew Christianson Sep 29 '11 at 1:59

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.