hmott
In C2 sin() and cos() take angles not degrees, so if the value is in radians you need to convert it to degrees inside sin and cos. Also in the context of this equation it expects angle() to give a value in radians instead of degrees, so you'll need to convert it.
So literally it would be this:
r = 6371000
phi1 = lat1*pi/180
phi2 = lat2*pi/180
deltaPhi = (lat2-lat1)*pi/180
deltaLambda = (lng1-lng2)*pi/180
a = sin(deltaPhi/2*180/pi)^2 + cos(phi1*180/pi)*cos(phi2*180/pi)*sin(deltaLambda/2*180/pi)^2
c = 2*angle(0,0,sqrt(1-a),sqrt(a))*pi/180
d = r*c
But you can cut out most of the radian conversions and get just this:
r = 6371000
a = sin((lat2-lat1)/2)^2 + cos(lat1)*cos(lat2)*sin((lng1-lng2)/2)^2
c = 2*angle(0,0,sqrt(1-a),sqrt(a))*pi/180
d = r*c