summaryrefslogtreecommitdiff
path: root/2d/vector2.scm
diff options
context:
space:
mode:
authorDavid Thompson <dthompson@member.fsf.org>2013-09-15 22:52:54 -0400
committerDavid Thompson <dthompson@member.fsf.org>2013-09-15 22:52:54 -0400
commit08b9aeecc8b338ebcbc577e2aca304c5cac88baa (patch)
tree6735df54fdb11b3ba1d6f4a84c3c6d3b0f97e5c1 /2d/vector2.scm
parent9efc09b4f5cf61158504d7255069e2c56a102b13 (diff)
Clean up docstrings for vector2 module.
Diffstat (limited to '2d/vector2.scm')
-rw-r--r--2d/vector2.scm26
1 files changed, 13 insertions, 13 deletions
diff --git a/2d/vector2.scm b/2d/vector2.scm
index d231f93..3993fb6 100644
--- a/2d/vector2.scm
+++ b/2d/vector2.scm
@@ -53,12 +53,12 @@
(define identity-vector2 (vector2 1 1))
(define (vector2-polar r theta)
- "Converts polar coordinates into a cartesian vector."
+ "Convert the polar coordinates (R, THETA) into a cartesian vector."
(vector2 (* r (cos theta))
(* r (sin theta))))
(define (v+ . vectors)
- "Adds vectors."
+ "Return the sum of all VECTORS."
(define (add-vectors x y vectors)
(cond ((null? vectors)
(vector2 x y))
@@ -69,7 +69,7 @@
(add-vectors 0 0 vectors))
(define (v* . vectors)
- "Multiplies vectors."
+ "Return the product of all VECTORS."
(define (multiply-vectors x y vectors)
(cond ((null? vectors)
(vector2 x y))
@@ -80,17 +80,17 @@
(multiply-vectors 1 1 vectors))
(define (vscale v scalar)
- "Multiply vector by a scalar."
+ "Multiply the vector V by a scalar value."
(vector2 (* (vx v) scalar)
(* (vy v) scalar)))
(define (vmag v)
- "Returns the magnitude of a vector"
+ "Return the magnitude of the vector V."
(sqrt (+ (expt (vx v) 2)
(expt (vy v) 2))))
(define (vnorm v)
- "Normalizes a vector."
+ "Normalize the vector V."
(let ((m (vmag v)))
(if (zero? m)
null-vector2
@@ -98,22 +98,22 @@
(/ (vy v) m)))))
(define (vdot v1 v2)
- "Returns the dot product of two vectors."
+ "Return the dot product of the vectors V1 and V2."
(+ (* (vx v1) (vx v2))
(* (vy v1) (vy v2))))
(define (vcross v1 v2)
- "Returns the cross product of two vectors. The cross product of a 2D
-vector is not defined. This function instead returns the Z coordinate
-of the cross product as if the vectors were in 3D space."
+ "Return the cross product of the vectors V1 and V2. Technically, the
+cross product of a 2D vector is not defined. This function instead
+returns the Z coordinate of the cross product as if the vectors were
+in 3D space."
(- (* (vx v1) (vy v2))
(* (vy v1) (vx v2))))
(define (vector2-translate v)
- "Perform an OpenGL translate matrix operation with the given
-vector2."
+ "Perform an OpenGL translate operation with the vector V."
(gl-translate (vx v) (vy v) 0))
(define (vector2-scale v)
- "Perform an OpenGL scale matrix operation with the given vector2."
+ "Perform an OpenGL scale operation with the vector V."
(gl-scale (vx v) (vy v) 1))