2
$\begingroup$

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.

$\endgroup$
3
  • $\begingroup$ Do you know the coordinates of a_i? Do you know how to get line equations? Are a_i any in the plan or have some limits? Can you select the coordinate system - such as a_3=(0,0))? $\endgroup$
    – Moti
    Jan 29, 2022 at 18:45
  • $\begingroup$ @Moti all points of a are defined. $\endgroup$
    – Hozeis
    Jan 30, 2022 at 15:36
  • $\begingroup$ I assume problem solved. $\endgroup$
    – Moti
    Jan 31, 2022 at 16:52

1 Answer 1

1
$\begingroup$

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.

$\endgroup$
14
  • $\begingroup$ 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. $\endgroup$
    – Hozeis
    Jan 30, 2022 at 15:20
  • 1
    $\begingroup$ Hi. It's easier to call the angle $2A$ since we need to halve it in the distance formula. $\endgroup$
    – user502266
    Jan 30, 2022 at 15:25
  • $\begingroup$ Gotcha. Thanks alot. $\endgroup$
    – Hozeis
    Jan 30, 2022 at 15:34
  • $\begingroup$ 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? $\endgroup$
    – Hozeis
    Jan 31, 2022 at 18:43
  • $\begingroup$ 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)$. $\endgroup$
    – user502266
    Jan 31, 2022 at 18:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .