# Talk:LlVecDist

From Second Life Wiki

Revision as of 11:49, 1 April 2013 by MartinRJ Fayray (Talk | contribs)

### Example script to calculate the distance of a vector-point from a 'line' (using Heron's formula)

<lsl> float fDistanceOfPointFromLine(vector veca, vector vecb, vector vecc) { //vecc is the point (veca and vecb are points on the line)

float a = llVecDist(vecb, vecc); float b = llVecDist(veca, vecc); float c = llVecDist(veca, vecb); float s=(1.0/2.0)*(a+b+c); float hc =(2.0/c)*llSqrt(s*(s-a)*(s-b)*(s-c)); return hc;

} </lsl> --MartinRJ Fayray 11:49, 1 April 2013 (PDT)