How to get x in radius percentage value?

Hello there,
How to find the percentage value from A to B when I know the X value in between these two points?

I created this picture to kind of illustrate what I mean better.

5855623--622108--Example_Circle.png

I wrote this function which gets the percentage, but how do I also include the center offset?

private float GetPercentage(Vector2 point, float radiusOffset, float centerOffset)
{
    float radius = Math.Min(circle.rect.width / 2f, circle.rect.height / 2f);

    radius *= radiusOffset;

    return 1f - (Math.Max(Math.Abs(point.x), Math.Abs(point.y)) / radius);
}

The radius offset is from 0-1, 0 being the 0,0 position and 1 full radius. The center offset is from 1-0, 1 being the 0,0 position and 0 being the radius border.

I can’t figure out what that function you wrote is trying to do. Line 3 is definitely a bad idea, and may not even compile, since you are trying to create a new variable “radius” in terms of some other variable also called “radius”.

Here’s what I’d do:

First, convert into a 1-dimensional problem by expressing everything in terms of the distance from the center. In your picture, you should end up with float a = 22.5; float b = 15; float x = 17.2. (How to calculate that from centerOffset, radiusOffset, and point is not clear from your picture, because you labeled the circles instead of the distances.)

Then, assuming b < a, the percentage from B to A is (x - b) / (a - b). The percentage from A to B is 1 - that.