summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2017-04-06 10:29:32 -0400
committerDavid Thompson <dthompson2@worcester.edu>2017-04-25 20:36:46 -0400
commit78a0e2a289a076814cb404190a3ae6556b9f5a1a (patch)
tree9a1a83c3ce360038e2301960061eb3e27d5feb54
parent6a182194d6bf70dac37e18d4c63c56314018147c (diff)
math: Add pi constant.
* chickadee/math.scm (pi): New variable. * doc/api.texi (Math): Add "Basics" subsection.
-rw-r--r--chickadee/math.scm7
-rw-r--r--doc/api.texi15
2 files changed, 21 insertions, 1 deletions
diff --git a/chickadee/math.scm b/chickadee/math.scm
index 3bcda52..adb7d8b 100644
--- a/chickadee/math.scm
+++ b/chickadee/math.scm
@@ -16,12 +16,17 @@
;;; <http://www.gnu.org/licenses/>.
(define-module (chickadee math)
- #:export (square
+ #:export (pi
+ pi/2
+ square
clamp
min
max)
#:replace (min max))
+(define pi 3.14159265358979323846)
+(define pi/2 (/ pi 2.0))
+
(define-inlinable (square x)
(* x x))
diff --git a/doc/api.texi b/doc/api.texi
index 9c568d5..e1f6acc 100644
--- a/doc/api.texi
+++ b/doc/api.texi
@@ -406,11 +406,26 @@ with vectors and matrices and axis-aligned bounding box collision
detection.
@menu
+* Basics:: Commonly used, miscellaneous things.
* Vectors:: Euclidean vectors.
* Matrices:: Transformation matrices.
* Rectangles:: Axis-aligned bounding boxes.
@end menu
+@node Basics
+@subsection Basics
+
+@defvar {Scheme Variable} pi
+An essential constant for all trigonometry. @code{@U{03C0}} is the ratio
+of a circle's circumferences to its diameter. Since @code{@U{03C0}} is an
+irrational number, the @var{pi} in Chickadee is a mere floating point
+approximation that is ``good enough.''
+@end defvar
+
+@defvar {Scheme Variable} pi/2
+Half of @var{pi}.
+@end defvar
+
@node Vectors
@subsection Vectors