hexagon logo

Distance between a hit and a cone (surface)

Just a funny code to calculate the distance of the hits of a cone to the cone surface :

DECIMAL PLACE,6 (metric, more if inches...)
ASSIGN/V1=CON1.HIT[1..CON1.NUMHITS].XYZ-CON1.XYZ................................................array of vectors between each hit and the cone summit
ASSIGN/L_V1=SQRT(DOT(V1,V1)).............................................................................................array of lengthes of vectors
ASSIGN/H_V1=DOT(V1,CON1.IJK).............................................................................................array of lengthes projection of hits along cone axis
ASSIGN/R_V1=SQRT(L_V1^2-H_V1^2).....................................................................................array of radial distances between hits and cone axis
ASSIGN/A_V1=ASIN(R_V1/L_V1)-DEG2RAD(CON1.A/2)......................................................array of angles
ASSIGN/T_VAL_HIT=L_V1*SIN(A_V1).......................................................................................array of distances of each hit to the surface (like a T_value for each hit)
Then calculate max, min max index....

Not sure it's usefull, not sure there's not an easiest way to do it, just funny to program using a little trig and the assignments tool box !