Hexagon boundary What is the easiest algebraic way to clip the arrow to stay within the hexagon?
Edit:  the only known parameters are the arrow end locations $\ x_0 $ and  $\ y_0 $ and hexagon outer radius $\ R $.  The hexagon origin is at $\ [0,0] $.

 A: Assume the hexagon is aligned like what is on the picture. Define a norm on $\mathbb{R}^2$ by
$$N(x,y) 
= \max\left\{ |y|, 
\left|\frac{y+x\sqrt{3}}{2}\right|,\left|\frac{y-x\sqrt{3}}{2}\right| 
\right\}
= \max\left\{
|y|, \frac{|y| + \sqrt{3}|x|}{2}\right\}
$$
The "circle" under this norm, i.e. the locus of the equation $N(x,y) = r = \frac{\sqrt{3}}{2}R$, will be a regular hexagon centered at origin with height $2r$, in-radius $ r$ and circum-radius $R$. 
To clip your arrow start at $(0,0)$ and end at $(x,y)$ within such a hexagon,


*

*Compute the norm $d = N(x,y)$. 

*If $d \le r$, your arrow is completely within the hexagon. 

*Otherwise, clip the arrow at point $(\frac{rx}{d}, \frac{ry}{d})$.


As long as the arrow start at $(0,0)$, you can apply the same trick for clipping
over other shapes.
For example, for a regular octagon with height $2r$, you can replace $N(x,y)$ above by
  $$\max\left\{ |x|, |y|, \frac{|x+y|}{\sqrt{2}}, \frac{|x-y|}{\sqrt{2}} \right\} = \max\left\{ |x|, |y|, \frac{|x|+|y|}{\sqrt{2}} \right\}$$
For an ellipse with semi-major/minor axes $a$ and $b$, you can set $r$ to $1$ and $N(x,y)$ to $\displaystyle\;\sqrt{\frac{x^2}{a^2} + \frac{y^2}{b^2}}$.
