Move a point to another using scale

Hello,

I have a cylinder and I want to move his bottom center point to another point using Y scale.
Here is a sketch of what I want:

I try to do this, but without success:

float distance1 = P1.y - P2.y;
float distance2 = P1.y - P3.y;

float new scaleY = (distance1 * scale.y) / distance2;

I know the position of P1, P2, P3 and the scale of the cylinder.
How to find the new scale?

Thanks

good day.

do you want to fix top of cylinder ?

if you don’t .you only put distance1 and distance2 in the wrong order.

 float d12 = P1.y - P2.y;
 float d13 = P1.y - P3.y;
 
 float scaleY = scale.y*d13/d12;

if not, check this

        float l1 = d12 * 2;
        float l0 = l1 / transform.localScale.y;
        float l2 = d12 + d13;

        float scaleY = transform.localScale.y * (l2 / l1);
        float offsetY = -(scaleY - transform.localScale.y) * l0 / 2;

        transform.localScale = new Vector3(1, scaleY);
        transform.position += new Vector3(0, offsetY);