find min, max ratio to interpolate triangle points by two angles based on arc

92 Views Asked by At

Summary:

Animation

We have parametric $j$ - mininal angle in radians, $k$ - maximal angle in radians and $r$ - arc radius, $d$ - arc diameter, $C$ - center

Green $45\deg$ arc:

$Ax=Cx+cos(j)*r$, $Ay=Cy+sin(j)*r$

$Bx=Cx+cos(k)*r$, $By=Cy+sin(k)*r$

Red $\triangle DEC$ triangle:

to limit it with given min, max angles i just lineary interpolate positions of edges points (D and E) $$Dx=Cx-r+d*Xmin, Ex=Cx-r+d*Xmax; Dy=Ey=Cy-r$$ and normalized ratio is calculated next: $$Xmin=\frac{j - u}{v-u}; Xmax=\frac{k - u}{v-u};$$

where $u=3*\frac{\pi}{2}$, $v=4*\frac{\pi}{2}$

Issue: interpolated points positions of triangle have same angles as green arc but goes outside arc bounds a little bit sometimes (horizontally). How to calculate proper interpolation ratios to always keep red triangle in bounds of arc?

1

There are 1 best solutions below

5
On BEST ANSWER

Points $A$, $C$, $D$ are aligned if there exists a number $t$ such that: $$ D=C+(A-C)t. $$ Insert there $D_y=C_y-r$ and solve for $t$, to find $$ t=-{r\over A_y-C_y}. $$ Then substitute back into the first equation to get $$ D_x=C_x-(A_x-C_x){r\over A_y-C_y}. $$ Do the same for points $B$, $C$, $E$.