If your project goes into production in a few months, you can use JavaScript in CSPro 8.0 and use a library like the code here:
https://www.npmjs.com/package/utm-latlng?activeTab=code
However, in the meantime, if you want to program this in CSPro, you can use these math functions as Taylor series approximations of the math functions that you need that are not available in CSPro logic:
// because these math functions don't exist in CSPro, we need to approximate them using Taylor series
function fm_fact(val)
numeric result = 1;
do val = val while val >= 2 by -1
result = result * val;
enddo;
fm_fact = result;
end;
numeric fm_pi = 3.14159265359;
function fm_deg2rad(angle)
fm_deg2rad = angle * fm_pi / 180;
end;
function fm_rad2deg(angle)
fm_rad2deg = angle / fm_pi * 180;
end;
function fm_sin(angle)
numeric result,idx = 1;
while 1 do
numeric calculation = ( angle ^ idx ) / fm_fact(idx);
if calculation = default then
break;
endif;
if idx % 4 = 1 then
result = result + calculation;
else
result = result - calculation;
endif;
inc(idx,2);
enddo;
fm_sin = result;
end;
function fm_cos(angle)
numeric result = 1, idx = 2;
while 1 do
numeric calculation = ( angle ^ idx ) / fm_fact(idx);
if calculation = default then
break;
endif;
if idx % 4 = 2 then
result = result - calculation;
else
result = result + calculation;
endif;
inc(idx,2);
enddo;
fm_cos = result;
end;
function fm_asin(sin)
numeric result = sin, idx = 3;
numeric numNumer = 1,numDenom = 2;
while 1 do
numeric calculation = ( numNumer / numDenom ) * ( sin ^ idx / idx );
if calculation = default then
break;
endif;
inc(result, calculation);
numNumer = numNumer * idx;
numDenom = numDenom * ( idx + 1 );
inc(idx,2);
enddo;
fm_asin = result;
end;
function fm_atan(tan)
fm_atan = fm_asin(tan / sqrt(tan ^ 2 + 1));
end;
function fm_atan2(y,x)
if x > 0 then fm_atan2 = fm_atan(y / x);
elseif y >= 0 and x < 0 then fm_atan2 = fm_pi + fm_atan(y / x);
elseif y < 0 and x < 0 then fm_atan2 = -1 * fm_pi + fm_atan(y / x);
elseif y > 0 and x = 0 then fm_atan2 = fm_pi / 2;
elseif y < 0 and x = 0 then fm_atan2 = -1 * fm_pi / 2;
elseif y = 0 and x = 0 then fm_atan2 = default;
endif;
end;