/* * display diameter (awgd()) and area (awga()) in mm and mm², * given AWG number (American wire gauge) * * Copyright 2011 Sami Farin * Released to Public Domain */ config("resource_debug", 0),; /* Do not print "xxx() defined" */ define awgd() { local argc; /* number of args given */ local d; local res; argc = param(0); if (argc != 1) { quit "usage: awgd(num) [num=AWG number (-3 .. 40)]"; } d = param(1); if (d < -3 || d > 40) { quit "number must be from -3 to 40"; } res = exp(1)^(2.1104-(0.11594*d)); return res; } define awga() { local argc; /* number of args given */ local a; local res; argc = param(0); if (argc != 1) { quit "usage: awga(num) [num=AWG number (-3 .. 40)]"; } a = param(1); if (a < -3 || a > 40) { quit "number must be from -3 to 40"; } res = 0.012668 * 92^((36-a)/19.5); return res; }