2

I am writing a application that needs to calculate the inner stroke of a shape. To understand more of what I mean, imagine we had a shape represented by the black outline of the image bellow. We than applied a inner stroke effect of 5 to that shape (represented by the yellow). I would now like to determine the values of points b0,b1,b2,b3. Since this application needs to be fast, I need the solution with the least amount of steps.

enter image description here

So far this is what I have come up with:

Intersection of parallel lines

The main solution I have thought of is getting the parallel lines of a0,a3 and a3,a2 with a distance of 5 (represented by line1 and line2). I would then calculate the intersection point of these two lines and this would determine the point b3. I would then repeat this step for the remaining points. This option requires multiple steps;

  1. get the perpendicular line of side a0,a3. --> PerpA0,A3
  2. get intersecting point of a0,a3 and PerpA0,A3 --> point #2
  3. use line PerpA0,A3 , point #2 and the distance of 5 to calculate point #3 example
  4. find the equation of the line that runs perpendicular to PerpA0,A3 and passes through point #3 giving us line1
  5. repeat the above steps for side a3,a2 --> line2
  6. calculate the point of intersection between line1 and line2 giving us point b3

enter image description here

I'm no math guru and don't know if this is the best solution for getting these values, If anyone could assist me I would be grateful. Also this is my first math post. Thanks.

Hozeis
  • 143

1 Answers1

1

Let the internal angle at a corner be $2A$. Then the corresponding '$b$' point is on the bisector of the angle at a distance $$\frac{5}{\sin A}$$ from the corner.

That should be easy to implement but ask if you are unclear.

  • Thanks for the answer, I will mark it as the correct answer once I test it tomorrow. Im just a little confused on the "Let the internal angle at a corner be 2A", what is the 2, or is this a misspell. – Hozeis Jan 30 '22 at 15:20
  • 1
    Hi. It's easier to call the angle $2A$ since we need to halve it in the distance formula. –  Jan 30 '22 at 15:25
  • Gotcha. Thanks alot. – Hozeis Jan 30 '22 at 15:34
  • how do i get the equation for the bisector line. Ive looked around but am just confusing ideas. Just to make sure im on track, I would then use the distance calculated from point a3 on the bisector line to get my result? – Hozeis Jan 31 '22 at 18:43
  • If $a_3$ is $(x,y)$ then $b_3$ is $(x+5,y+5)$. This can be seen very easily without a formula, but the formula I gave you would work as follows. $A=45$ and so the distance is $d=5/\sin45$ then the coordinates of $b_3$ are $(x+d \cos45,y+d \sin45)$. –  Jan 31 '22 at 18:52
  • One more thing if you could advise me. Im getting the internal corner using the "The Law of Cosines". In this case I have to calculate the distance between points a0,a3,a2 then apply C = arccos((c² - a² - b² )/(2ab). This is working fine, I was just wondering if you know a faster way. Thanks again. – Hozeis Jan 31 '22 at 21:26
  • Yes, from the given coordinates of general points that is probably the best method. However, there may well be quicker methods in special cases - if for example you can easily find right-angled triangles. –  Jan 31 '22 at 21:33
  • Ok thank, In those cases I would just use sin, cos, and tan right. SOHCAHTOA - im catching on. :) – Hozeis Jan 31 '22 at 21:42
  • That is exactly right. –  Jan 31 '22 at 21:43
  • So I have been testing out this answer, the distance formula works great for all points, but the (x+dcos45,y+dsin45) does not doo the trick to find the coordinates of other values b0,b1,b3. Does this (x+dcos45,y+dsin45) only work for corners with 90°. Heres my math https://www.geogebra.org/geometry/tmqdquyf – Hozeis Feb 01 '22 at 21:14
  • Yes, that was only for the 90 angle. –  Feb 01 '22 at 21:17
  • that only gives me two point then, my primary concern is non 90° angles. Any guidence on non 90° angles – Hozeis Feb 01 '22 at 21:24
  • Im asuming im going to have to determine the bisector line function and then move d distance on that line – Hozeis Feb 01 '22 at 21:31
  • You need the angle V it makes with the x-axis. Then dcos(V) measures the distance moved in the x-axis etc –  Feb 01 '22 at 21:34