mirror of
https://github.com/lcn2/calc.git
synced 2025-08-16 01:03:29 +03:00
Completed degree, radian, gradian builtin conversions
Updated CHANGES. Updated help/unexpected. Added help files for d2g(), d2r(), g2d(), g2r(), r2d(), r2g(). Added regression test code for the same functions. Fixed a few minor typos.
This commit is contained in:
23
CHANGES
23
CHANGES
@@ -36,6 +36,25 @@ The following are the changes from calc version 2.14.0.0 to date:
|
||||
a call to base2(1000) would make calc unstable and likely to
|
||||
dump core.
|
||||
|
||||
Added builtin functions to convert between degrees, radians
|
||||
and gradians:
|
||||
|
||||
d2r(deg) - given degrees returns radians
|
||||
g2r(grad) - given gradians returns radians
|
||||
|
||||
r2d(rad) - given radians returns degrees
|
||||
g2d(grad) - given gradians returns degrees
|
||||
|
||||
r2g(rad) - given radians returns gradians
|
||||
d2g(deg) - given degrees returns gradians
|
||||
|
||||
Add 6 functions take a 2nd optional epsilon argument.
|
||||
For d2r(deg, ep), r2d(rad, ep), the optional 2nd epsilon argument controls
|
||||
the precision of the internal constant pi/180.
|
||||
For g2r(grad, ep), r2g(rad, ep), the optional 2nd epsilon argument controls
|
||||
the precision of the internal constant pi/200.
|
||||
The optional 2nd argument is ignored by g2d(grad, ep) and d2g(deg, ep).
|
||||
|
||||
|
||||
The following are the changes from calc version 2.13.0.1 to 2.13.0.1:
|
||||
|
||||
@@ -74,7 +93,7 @@ The following are the changes from calc version 2.13.0.0 to 2.13.0.0:
|
||||
|
||||
Fixed typo (missing quotes) in the env rule.
|
||||
|
||||
Fixed intendation problem in CHANGES.
|
||||
Fixed indentation problem in CHANGES.
|
||||
|
||||
Combined 2.12.9.1 changes into the 2.12.8.2 to 2.12.9.0
|
||||
range, and thus renamed the range to 2.12.8.2 to 2.12.9.1.
|
||||
@@ -110,7 +129,7 @@ The following are the changes from calc version 2.13.0.0 to 2.13.0.0:
|
||||
#!/usr/local/bin/calc -f
|
||||
...
|
||||
|
||||
It is common that -q be usde with a calc script, so assuming the
|
||||
It is common that -q be used with a calc script, so assuming the
|
||||
same /usr/local/bin/calc path:
|
||||
|
||||
#!/usr/local/bin/calc -q -f
|
||||
|
@@ -3400,9 +3400,79 @@ define test_trig()
|
||||
|
||||
print '3400: Beginning test_trig';
|
||||
|
||||
/* test 3401-3407 */
|
||||
tnum = test3400(1, 3401);
|
||||
vrfy(tnum == 3407, '3407: tnum == 3407');
|
||||
|
||||
print tnum: ': Ending test_trig';
|
||||
/* d2r & r2d */
|
||||
vrfy(d2r(180) == pi(),
|
||||
'3408: d2r(180) == pi()');
|
||||
vrfy(d2r(180, 1e-100) == pi(1e-100),
|
||||
'3409: d2r(180, 1e-100) == pi(1e-100)');
|
||||
vrfy(r2d(pi()/2) == 90,
|
||||
'3410: r2d(pi()/2) == 90');
|
||||
vrfy(r2d(pi(1e-15)/2) == 14137166941154068500000/157079632679489661923,
|
||||
'3411: r2d(pi(1e-15)/2) == ' +
|
||||
'14137166941154068500000/157079632679489661923');
|
||||
vrfy(r2d(d2r(40)) == 40,
|
||||
'3412: r2d(d2r(40)) == 40');
|
||||
vrfy(r2d(d2r(40,1e-90),1e-90) == 40,
|
||||
'3413: r2d(d2r(40,1e-90),1e-90) == 40');
|
||||
vrfy(d2r(180i) == 1i*pi(),
|
||||
'3414: d2r(1808) == 1i*pi()');
|
||||
vrfy(d2r(180i+90) == 1i*pi() + pi()/2,
|
||||
'3415: d2r(180i+90) == 1i*pi() + pi()/2');
|
||||
vrfy(r2d(d2r(40+40i)) == 40+40i,
|
||||
'3416: r2d(d2r(40+40i)) == 40+40i');
|
||||
vrfy(r2d(d2r(40+40i,1e-60),1e-60) == 40+40i,
|
||||
'3417: r2d(d2r(40+40i,1e-60),1e-60) == 40+40i');
|
||||
|
||||
/* g2r & r2g */
|
||||
vrfy(g2r(200) == pi(),
|
||||
'3418: g2r(200) == pi()');
|
||||
vrfy(g2r(200, 1e-100) == pi(1e-100),
|
||||
'3419: g2r(180, 1e-100) == pi(1e-100)');
|
||||
vrfy(r2g(pi()/2) == 100,
|
||||
'3420: r2g(pi()/2) == 100');
|
||||
vrfy(r2g(pi(1e-15)/2) == 15707963267948965000000/157079632679489661923,
|
||||
'3421: r2g(pi(1e-15)/2) == ' +
|
||||
'15707963267948965000000/157079632679489661923');
|
||||
vrfy(r2g(g2r(40)) == 40,
|
||||
'3422: r2g(g2r(40)) == 40');
|
||||
vrfy(r2g(g2r(40,1e-90),1e-90) == 40,
|
||||
'3423: r2g(g2r(40,1e-90),1e-90) == 40');
|
||||
vrfy(g2r(200i) == 1i*pi(),
|
||||
'3424: g2r(200i) == 1i*pi()');
|
||||
vrfy(g2r(200i+150) == pi()*0.75 + 1i*pi(),
|
||||
'3425: g2r(200i+150) == pi()*0.75 + 1i*pi()');
|
||||
vrfy(r2g(g2r(40+40i)) == 40+40i,
|
||||
'3426: r2g(g2r(40+40i)) == 40+40i');
|
||||
vrfy(r2g(g2r(40+40i,1e-60),1e-60) == 40+40i,
|
||||
'3427: r2g(g2r(40+40i,1e-60),1e-60) == 40+40i');
|
||||
|
||||
/* g2d & d2g */
|
||||
vrfy(g2d(200) == 180,
|
||||
'3428: g2d(200) == 180');
|
||||
vrfy(g2d(200, 1e-100) == 180,
|
||||
'3429: g2d(180, 1e-100) == 180');
|
||||
vrfy(d2g(81) == 90,
|
||||
'3430: d2g(81) == 90');
|
||||
vrfy(d2g(pi(1e-15)/2) == 3141592653589793/1800000000000000,
|
||||
'3431: d2g(pi(1e-15)/2) == 3141592653589793/1800000000000000');
|
||||
vrfy(d2g(g2d(40)) == 40,
|
||||
'3432: d2g(g2d(40)) == 40');
|
||||
vrfy(d2g(g2d(40,1e-90),1e-90) == 40,
|
||||
'3433: d2g(g2d(40,1e-90),1e-90) == 40');
|
||||
vrfy(g2d(200i) == 180i,
|
||||
'3434: g2d(200i) == 180i');
|
||||
vrfy(g2d(200i+47) == 42.3 + 180i,
|
||||
'3435: g2d(200i+47) == 42.3 + 180i');
|
||||
vrfy(d2g(g2d(40+40i)) == 40+40i,
|
||||
'3436: d2g(g2d(40+40i)) == 40+40i');
|
||||
vrfy(d2g(g2d(40+40i,1e-90),1e-90) == 40+40i,
|
||||
'3437: d2g(g2d(40+40i,1e-90),1e-90) == 40+40i');
|
||||
|
||||
print '3438: Ending test_trig';
|
||||
}
|
||||
print '051: parsed test_trig()';
|
||||
|
||||
|
@@ -356,7 +356,7 @@ BLT_HELP_FILES= ${BLT_HELP_FILES_3} ${BLT_HELP_FILES_5} \
|
||||
#
|
||||
# Please use:
|
||||
#
|
||||
# make detail_help_list
|
||||
# make clobber >/dev/null && make detail_help_list
|
||||
#
|
||||
# to keep this list in nice sorted order.
|
||||
#
|
||||
@@ -364,32 +364,32 @@ DETAIL_HELP= abs access acos acosh acot acoth acsc acsch address agd \
|
||||
append appr arg argv arrow asec asech asin asinh assign atan atan2 \
|
||||
atanh avg base base2 bernoulli bit blk blkcpy blkfree blocks bround \
|
||||
btrunc calc_tty calclevel calcpath catalan ceil cfappr cfsim char \
|
||||
cmdbuf cmp comb conj cos cosh cot coth count cp csc csch ctime delete \
|
||||
den dereference det digit digits display dp epsilon errcount errmax \
|
||||
errno error estr euler eval exp fact factor fclose fcnt feof ferror \
|
||||
fflush fgetc fgetfield fgetfile fgetline fgets fgetstr fib files floor \
|
||||
fopen forall fpathopen fprintf fputc fputs fputstr frac free \
|
||||
freebernoulli freeeuler freeglobals freeredc freestatics frem freopen \
|
||||
fscan fscanf fseek fsize ftell gcd gcdrem gd getenv hash head highbit \
|
||||
hmean hnrmod hypot ilog ilog10 ilog2 im indices inputlevel insert int \
|
||||
inverse iroot isalnum isalpha isassoc isatty isblk iscntrl isconfig \
|
||||
isdefined isdigit iserror iseven isfile isgraph ishash isident isint \
|
||||
islist islower ismat ismult isnull isnum isobj isobjtype isodd isprime \
|
||||
isprint isptr ispunct isqrt isrand israndom isreal isrel issimple \
|
||||
isspace issq isstr istype isupper isxdigit jacobi join lcm lcmfact \
|
||||
lfactor ln log lowbit ltol makelist matdim matfill matmax matmin \
|
||||
matsum mattrace mattrans max memsize meq min minv mmin mne mod modify \
|
||||
name near newerror nextcand nextprime norm null num oldvalue ord param \
|
||||
perm pfact pi pix places pmod polar poly pop popcnt pound power \
|
||||
prevcand prevprime printf prompt protect ptest push putenv questions \
|
||||
quo quomod rand randbit random randombit randperm rcin rcmul rcout \
|
||||
rcpow rcsq re remove reverse rewind rm root round rsearch runtime \
|
||||
saveval scale scan scanf search sec sech seed segment select sgn sha1 \
|
||||
sin sinh size sizeof sleep sort sqrt srand srandom ssq stoponerror str \
|
||||
strcasecmp strcat strcmp strcpy strerror strlen strncasecmp strncmp \
|
||||
strncpy strpos strprintf strscan strscanf strtolower strtoupper substr \
|
||||
sum swap system systime tail tan tanh test time trunc usertime version \
|
||||
xor
|
||||
cmdbuf cmp comb conj cos cosh cot coth count cp csc csch ctime d2g d2r \
|
||||
delete den dereference det digit digits display dp epsilon errcount \
|
||||
errmax errno error estr euler eval exp fact factor fclose fcnt feof \
|
||||
ferror fflush fgetc fgetfield fgetfile fgetline fgets fgetstr fib \
|
||||
files floor fopen forall fpathopen fprintf fputc fputs fputstr frac \
|
||||
free freebernoulli freeeuler freeglobals freeredc freestatics frem \
|
||||
freopen fscan fscanf fseek fsize ftell g2d g2d.bak g2r gcd gcdrem gd \
|
||||
getenv hash head highbit hmean hnrmod hypot ilog ilog10 ilog2 im \
|
||||
indices inputlevel insert int inverse iroot isalnum isalpha isassoc \
|
||||
isatty isblk iscntrl isconfig isdefined isdigit iserror iseven isfile \
|
||||
isgraph ishash isident isint islist islower ismat ismult isnull isnum \
|
||||
isobj isobjtype isodd isprime isprint isptr ispunct isqrt isrand \
|
||||
israndom isreal isrel issimple isspace issq isstr istype isupper \
|
||||
isxdigit jacobi join lcm lcmfact lfactor ln log lowbit ltol makelist \
|
||||
matdim matfill matmax matmin matsum mattrace mattrans max memsize meq \
|
||||
min minv mmin mne mod modify name near newerror nextcand nextprime \
|
||||
norm null num oldvalue ord param perm pfact pi pix places pmod polar \
|
||||
poly pop popcnt pound power prevcand prevprime printf prompt protect \
|
||||
ptest push putenv quo quomod r2d r2g rand randbit random randombit \
|
||||
randperm rcin rcmul rcout rcpow rcsq re remove reverse rewind rm root \
|
||||
round rsearch runtime saveval scale scan scanf search sec sech seed \
|
||||
segment select sgn sha1 sin sinh size sizeof sleep sort sqrt srand \
|
||||
srandom ssq stoponerror str strcasecmp strcat strcmp strcpy strerror \
|
||||
strlen strncasecmp strncmp strncpy strpos strprintf strscan strscanf \
|
||||
strtolower strtoupper substr sum swap system systime tail tan tanh \
|
||||
test time trunc usertime version xor
|
||||
|
||||
# This list is of files that are clones of DETAIL_HELP files. They are
|
||||
# built from DETAIL_HELP files.
|
||||
|
55
help/d2g
Normal file
55
help/d2g
Normal file
@@ -0,0 +1,55 @@
|
||||
NAME
|
||||
d2g - convert degrees to gradians
|
||||
|
||||
SYNOPSIS
|
||||
d2g(x [,eps])
|
||||
|
||||
TYPES
|
||||
x number (real or complex)
|
||||
eps nonzero real, defaults to epsilon()
|
||||
|
||||
return number
|
||||
|
||||
DESCRIPTION
|
||||
Given x degrees, return the equivalent number of gradians.
|
||||
|
||||
The eps argument is ignored.
|
||||
|
||||
EXAMPLE
|
||||
; print d2g(45), d2g(180), d2g(30)
|
||||
50 200 ~33.33333333333333333333
|
||||
|
||||
; print d2g(3i+2)
|
||||
~2.22222222222222222222+~3.33333333333333333333i
|
||||
|
||||
LIMITS
|
||||
none
|
||||
|
||||
LINK LIBRARY
|
||||
none
|
||||
|
||||
SEE ALSO
|
||||
d2r, r2d, g2r, r2g, g2d,
|
||||
sin, cos, tan, sec, csc, cot, epsilon
|
||||
|
||||
## Copyright (C) 2021 Landon Curt Noll
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
## as published by the Free Software Foundation.
|
||||
##
|
||||
## Calc is distributed in the hope that it will be useful, but WITHOUT
|
||||
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
||||
## Public License for more details.
|
||||
##
|
||||
## A copy of version 2.1 of the GNU Lesser General Public License is
|
||||
## distributed with calc under the filename COPYING-LGPL. You should have
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
##
|
||||
## Under source code control: 2021/09/07 12:04:28
|
||||
## File existed as early as: 2021
|
||||
##
|
||||
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
59
help/d2r
Normal file
59
help/d2r
Normal file
@@ -0,0 +1,59 @@
|
||||
NAME
|
||||
d2r - convert degrees to radians
|
||||
|
||||
SYNOPSIS
|
||||
d2r(x [,eps])
|
||||
|
||||
TYPES
|
||||
x number (real or complex)
|
||||
eps nonzero real, defaults to epsilon()
|
||||
|
||||
return number
|
||||
|
||||
DESCRIPTION
|
||||
Given x degrees, return the equivalent number of radians.
|
||||
|
||||
The eps controls the precision of the calculated internal
|
||||
constant pi / 180.
|
||||
|
||||
EXAMPLE
|
||||
; print d2r(45), d2r(180), d2r(30)
|
||||
~0.78539816339744830962 3.14159265358979323846 ~0.52359877559829887308
|
||||
|
||||
; print d2r(3i+2)
|
||||
~0.03490658503988659154+~0.05235987755982988731i
|
||||
|
||||
; print sin(d2r(30)), cos(d2r(60)), tan(d2r(45))
|
||||
0.5 0.5 1
|
||||
|
||||
LIMITS
|
||||
eps > 0
|
||||
|
||||
LINK LIBRARY
|
||||
NUMBER *qpidiv180(NUMBER *eps)
|
||||
|
||||
SEE ALSO
|
||||
r2d, g2r, r2g, d2g, g2d,
|
||||
sin, cos, tan, sec, csc, cot, epsilon
|
||||
|
||||
## Copyright (C) 2021 Landon Curt Noll
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
## as published by the Free Software Foundation.
|
||||
##
|
||||
## Calc is distributed in the hope that it will be useful, but WITHOUT
|
||||
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
||||
## Public License for more details.
|
||||
##
|
||||
## A copy of version 2.1 of the GNU Lesser General Public License is
|
||||
## distributed with calc under the filename COPYING-LGPL. You should have
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
##
|
||||
## Under source code control: 2021/09/07 12:04:28
|
||||
## File existed as early as: 2021
|
||||
##
|
||||
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
55
help/g2d
Normal file
55
help/g2d
Normal file
@@ -0,0 +1,55 @@
|
||||
NAME
|
||||
g2d - convert gradians to degrees
|
||||
|
||||
SYNOPSIS
|
||||
g2d(x [,eps])
|
||||
|
||||
TYPES
|
||||
x number (real or complex)
|
||||
eps nonzero real, defaults to epsilon()
|
||||
|
||||
return number
|
||||
|
||||
DESCRIPTION
|
||||
Given x gradians, return the equivalent number of degrees.
|
||||
|
||||
The eps argument is ignored.
|
||||
|
||||
EXAMPLE
|
||||
; print g2d(50), g2d(200), g2d(30)
|
||||
45 180 27
|
||||
|
||||
; print g2d(3i+2)
|
||||
1.8+2.7i
|
||||
|
||||
LIMITS
|
||||
none
|
||||
|
||||
LINK LIBRARY
|
||||
none
|
||||
|
||||
SEE ALSO
|
||||
d2r, r2d, g2r, r2g, d2g,
|
||||
sin, cos, tan, sec, csc, cot, epsilon
|
||||
|
||||
## Copyright (C) 2021 Landon Curt Noll
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
## as published by the Free Software Foundation.
|
||||
##
|
||||
## Calc is distributed in the hope that it will be useful, but WITHOUT
|
||||
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
||||
## Public License for more details.
|
||||
##
|
||||
## A copy of version 2.1 of the GNU Lesser General Public License is
|
||||
## distributed with calc under the filename COPYING-LGPL. You should have
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
##
|
||||
## Under source code control: 2021/09/07 12:04:28
|
||||
## File existed as early as: 2021
|
||||
##
|
||||
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
59
help/g2r
Normal file
59
help/g2r
Normal file
@@ -0,0 +1,59 @@
|
||||
NAME
|
||||
g2r - convert gradians to radians
|
||||
|
||||
SYNOPSIS
|
||||
g2r(x [,eps])
|
||||
|
||||
TYPES
|
||||
x number (real or complex)
|
||||
eps nonzero real, defaults to epsilon()
|
||||
|
||||
return number
|
||||
|
||||
DESCRIPTION
|
||||
Given x gradians, return the equivalent number of radians.
|
||||
|
||||
The eps controls the precision of the calculated internal
|
||||
constant pi / 200.
|
||||
|
||||
EXAMPLE
|
||||
; print g2r(50), g2r(200), g2r(50)
|
||||
~0.78539816339744830962 3.14159265358979323846 ~0.78539816339744830962
|
||||
|
||||
; print g2r(3i+2)
|
||||
~0.03141592653589793238+~0.04712388980384689858i
|
||||
|
||||
; print sin(g2r(100/3)), cos(g2r(200/3)), tan(g2r(50))
|
||||
0.5 0.5 1
|
||||
|
||||
LIMITS
|
||||
eps > 0
|
||||
|
||||
LINK LIBRARY
|
||||
NUMBER *qpidiv200(NUMBER *eps)
|
||||
|
||||
SEE ALSO
|
||||
d2r, r2d, r2g, d2g, g2d,
|
||||
sin, cos, tan, sec, csc, cot, epsilon
|
||||
|
||||
## Copyright (C) 2021 Landon Curt Noll
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
## as published by the Free Software Foundation.
|
||||
##
|
||||
## Calc is distributed in the hope that it will be useful, but WITHOUT
|
||||
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
||||
## Public License for more details.
|
||||
##
|
||||
## A copy of version 2.1 of the GNU Lesser General Public License is
|
||||
## distributed with calc under the filename COPYING-LGPL. You should have
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
##
|
||||
## Under source code control: 2021/09/07 12:04:28
|
||||
## File existed as early as: 2021
|
||||
##
|
||||
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
57
help/r2d
Normal file
57
help/r2d
Normal file
@@ -0,0 +1,57 @@
|
||||
NAME
|
||||
r2d - convert radians to degrees
|
||||
|
||||
SYNOPSIS
|
||||
r2d(x [,eps])
|
||||
|
||||
TYPES
|
||||
x number (real or complex)
|
||||
eps nonzero real, defaults to epsilon()
|
||||
|
||||
return number
|
||||
|
||||
DESCRIPTION
|
||||
Given x radians, return the equivalent number of degrees.
|
||||
|
||||
The eps controls the precision of the calculated internal
|
||||
constant pi / 180.
|
||||
|
||||
EXAMPLE
|
||||
; pi = pi(1e-20)
|
||||
; print r2d(pi), r2d(pi/3), r2d(2*pi)
|
||||
180 60 360
|
||||
|
||||
; print r2d(pi+4i), r2d(pi/3 + 1i*pi), r2d(pi/5 + 5i*pi)
|
||||
180+~229.18311805232928350739i 60+180, 36+900i
|
||||
|
||||
LIMITS
|
||||
eps > 0
|
||||
|
||||
LINK LIBRARY
|
||||
NUMBER *qpidiv180(NUMBER *eps)
|
||||
|
||||
SEE ALSO
|
||||
d2r, g2r, r2g, d2g, g2d,
|
||||
sin, cos, tan, sec, csc, cot, epsilon
|
||||
|
||||
## Copyright (C) 2021 Landon Curt Noll
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
## as published by the Free Software Foundation.
|
||||
##
|
||||
## Calc is distributed in the hope that it will be useful, but WITHOUT
|
||||
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
||||
## Public License for more details.
|
||||
##
|
||||
## A copy of version 2.1 of the GNU Lesser General Public License is
|
||||
## distributed with calc under the filename COPYING-LGPL. You should have
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
##
|
||||
## Under source code control: 2021/09/07 12:04:28
|
||||
## File existed as early as: 2021
|
||||
##
|
||||
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
57
help/r2g
Normal file
57
help/r2g
Normal file
@@ -0,0 +1,57 @@
|
||||
NAME
|
||||
r2g - convert radians to gradians
|
||||
|
||||
SYNOPSIS
|
||||
r2g(x [,eps])
|
||||
|
||||
TYPES
|
||||
x number (real or complex)
|
||||
eps nonzero real, defaults to epsilon()
|
||||
|
||||
return number
|
||||
|
||||
DESCRIPTION
|
||||
Given x radians, return the equivalent number of gradians.
|
||||
|
||||
The eps controls the precision of the calculated internal
|
||||
constant pi / 200.
|
||||
|
||||
EXAMPLE
|
||||
; pi = pi()
|
||||
; print r2g(pi), r2g(pi/3), r2g(2*pi)
|
||||
200 ~66.66666666666666666667 400
|
||||
|
||||
; print r2g(pi+4i), r2g(pi/4 + 1i*pi), r2g(pi/5 + 5i*pi)
|
||||
200+~254.64790894703253723043i 50+200i 40+1000i
|
||||
|
||||
LIMITS
|
||||
eps > 0
|
||||
|
||||
LINK LIBRARY
|
||||
NUMBER *qpidiv200(NUMBER *eps)
|
||||
|
||||
SEE ALSO
|
||||
d2r, r2d, g2r, d2g, g2d,
|
||||
sin, cos, tan, sec, csc, cot, epsilon
|
||||
|
||||
## Copyright (C) 2021 Landon Curt Noll
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
## as published by the Free Software Foundation.
|
||||
##
|
||||
## Calc is distributed in the hope that it will be useful, but WITHOUT
|
||||
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
||||
## Public License for more details.
|
||||
##
|
||||
## A copy of version 2.1 of the GNU Lesser General Public License is
|
||||
## distributed with calc under the filename COPYING-LGPL. You should have
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
##
|
||||
## Under source code control: 2021/09/07 12:04:28
|
||||
## File existed as early as: 2021
|
||||
##
|
||||
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
@@ -228,7 +228,7 @@ Unexpected
|
||||
|
||||
1<<8/2
|
||||
|
||||
evalues to 128, not 16, because <<8 is performed before the /2.
|
||||
evaluates to 128, not 16, because <<8 is performed before the /2.
|
||||
|
||||
|
||||
&A[0] and A are different things in calc
|
||||
@@ -529,6 +529,34 @@ Unexpected
|
||||
; help fclose
|
||||
|
||||
|
||||
trig functions use only radians
|
||||
===============================
|
||||
|
||||
Some might be surprised to discover that all of the trigonometric in calc:
|
||||
|
||||
sin, cos, tan, sec, csc, cot
|
||||
asin, acos, atan, asec, acsc, acot
|
||||
|
||||
work in only radians.
|
||||
|
||||
Calc as builtin functions to convert between degrees, radians and gradians:
|
||||
|
||||
d2r(deg) - given degrees returns radians
|
||||
g2r(grad) - given gradians returns radians
|
||||
|
||||
r2d(rad) - given radians returns degrees
|
||||
g2d(grad) - given gradians returns degrees
|
||||
|
||||
r2g(rad) - given radians returns gradians
|
||||
d2g(deg) - given degrees returns gradians
|
||||
|
||||
For example, if you want to take the sin of 30 degrees, convert
|
||||
the 30 degrees into radians and pass the result to sin():
|
||||
|
||||
; print sin(d2r(30))
|
||||
0.5
|
||||
|
||||
|
||||
## Copyright (C) 1999-2007,2014,2017,2021 Landon Curt Noll
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
|
Reference in New Issue
Block a user