Sorry for the bad title, I have no idea how to describe my issue in a line.
As you can see in the simple diagram I made, I have a "ball" (circle) inside an isosceles triangle. I need my triangle to always "squeeze" (touch) the circle as it moves up and down. So as it moves up, the triangle gets smaller, and vice versa. I know the height of the triangle, the radius of the ball, and the height of the ball within the triangle. I just need to know how I can calculate the top side of the triangle to adjust it's width so it's touching the circle when I move it.
Let units center of circle is from bottom = h and w be the width to calculate.
w = 40 / (h^2-4)^1/2
With radius of 2, half the bottom angle = sin-1 (2/h) which is also = tan-1 (w/2 / 10)
Taking tan of both sides and squaring, simplifying ... solving for w:
2/h / (1 - (2/h)^2)^1/2 = w/2 / 10
w = 40 / (h^2 - 4)^1/2
In c#:
// given height from bottom 'h' and assuming 2 < h <= 8
public double GetWidth(double h)
{
return (40 / Math.Pow((Math.Pow(h, 2) - 4), 0.5));
}