How can I get the distance from point a to point b on a custom axis? (Includes pictures)

Trying to find the distance from point a to point b given a custom axis. I have some pictures to help me better explain:

I’m trying to find the distance from red to pink (or gray) on two custom axes. The axis from red to green (axis RG) and the axis from red to blue (axis RB). The colored lines are just to help show where the points are in 3D space. The “points” are located at the bottom of the colored lines shown. These colored lines just point straight up in the air for reference.

Here’s a link to a few more pictures for clarification.

I’ll give you a free copy of my game when it’s finished if you can help me out.

Here’s the psuedocode:

let v_rp be Vector from red to pink then,
v_rp = transform.poition of pink - transform.position of red

let d_rp be distance between red to pink then,
d_rp = v_rp.magnitude

ler v_rg be Vector from red to green then,
v_rg = transform.poition of green - transform.position of red

let theta be angle between v_rp and v_rg then,
theta = Vector3.Angle(v_rg, v_rp)

convert theta to radians
theta *= Mathf.Deg2Rad

then distance d between red to pink projected on the axis of red to green is given by:

d = d_rp / Mathf.Cos(theta)

That’s it. Now to get the same for on red to blue axis, just replace green by blue in the above pseudo code.

Rest remains the same.

Cheers!