4
$\begingroup$

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

  • 0
    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 and the left . C, then is V_AB + V_left and D is V_AB + V_right.2011-09-27

1 Answers 1

2

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'}=. 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: $$

We use that definition, along with S and b for formulate vectors $V_{left}$ & $V_{right}$ for the arrowheads: $V_{right} = $ $V_{left}=$ Then, Point C $=V_{B} +V_{left}$ and Point D $=V_B + V_{right}$.

  • 0
    You're welcome, glad to help.2011-09-29