[Math] Calculate miter points of stroked vectors in Cartesian plane

geometry

I have two vectors CA and CB which I 'stroked' with lines of width a and b. I need to calculate D and E points to draw miter joint between two stroked vectors.
What I know is:

  • A point coordinates
  • B point coordinates
  • C point coordinates
  • β angle
  • a length
  • b length

What I'm looking are coordinates of points D and E. I need to find universal formula that lets me to calculate those points at any β. (please see pic.1 below)

enter image description here

I can calculate those points if use stroke with same length for both vectors (a == b). I'm doing it by reflecting point C over vector AC with distance 0.5*a. Then I have right angle triangle, on which γ angle at point C equals 90° – (0.5 * β) angle. Therefore I have all three angles for the triangle and length of CF (half of a) which lets my to calculate coordinates of point D. (please see pic.2 below). I use triangle CGE to calculate E coordinates in the same way as above.

enter image description here

My problems start when I need to use different width for the vector's stroke (a != b) (please see pic.3 below). In that case when I draw CFD triangle I cannot calculate γ angle as it is not 90° – (0.5 * β) anymore and I have no idea how to calculate D and E coordinates. Can someone point me in the right direction how to find γ angle or if there is any other (better) way to calculate coordinates of D and E?

enter image description here

Best Answer

Draw two vectors $\vec u$ and $\vec v$ as in the picture below. They form a parallelogram having $a/2$ and $b/2$ as altitudes. It follows that $$ u={b\over 2\sin\beta},\quad v={a\over 2\sin\beta}. $$ It is then easy to compute $\vec u$ and $\vec v$: $$ \vec u={A-B\over AB}{b\over 2\sin\beta},\quad \vec v={C-B\over BC}{a\over 2\sin\beta} $$ and finally: $$ D=B+\vec u+\vec v,\quad E=B-\vec u-\vec v. $$

enter image description here

Related Question