Forgot about this thread.
Thanks for troubleshooting!
To better explain, I have 2 points.
pt0 = 0, 0, 0
pt1 = -3, 0, 2
This is just a test so I can verify if my math holds up. In the real scenario, both points can be anywhere on the ground plane.
I found the distance between both(hypotenuse) and a normalized vector pointing from pt0 to pt1. I'm also using a vector pointing to to the right angle(for the test, I made it 0,0,-1 )to form an imaginary triangle.
//get point positions
vector bottomP = point(1, "P", 0);
vector topP = point(1, "P", 1);
//get point Ns
vector bottomN = normalize(point(1, "N", 0));
vector topN = point(1, "N", 1);
//trigonometry to find ajacent Soh Cah Toa: using Cos = adj / hypo
//start by flattening on Y
vector bottomP2D = set(bottomP.x, 0, bottomP.z);
vector topP2D = set(topP.x, 0, topP.z);
float hypotenuse = distance(bottomP2D, topP2D);
float tempDot = dot(normalize(bottomN), normalize(topP2D-bottomP2D));
float radian = fit(tempDot, 1, -1, 0, $PI);
float adjLength = hypotenuse*cos(radian);
@adjLengthtest = adjLength; //should give 2 but result is 2.7589
-Olivier