3d-point-vector-data-types.lisp 1.86 KB
Newer Older
Dave Cooper's avatar
Dave Cooper committed
1
(in-package :geom-base)
2 3

(defun 3d-point? (point)
Dave Cooper's avatar
Dave Cooper committed
4 5
  "Boolean. A predicate function to check if a point is 3-dimensional."
  (3d-point-p point)
6 7 8
  )

(defun 3d-vector? (vector)
Dave Cooper's avatar
Dave Cooper committed
9
  "Boolean. A predicate function to check if a vector is 3-dimensional."
10 11 12 13 14 15
  (3d-vector-p vector)
  )

(deftype 3d-point ()
  "Datatype 3d-point is the result of a make-point function using 3 coordinates
  (e.g., X, Y & Z), not an instance of the define-object point"
Dave Cooper's avatar
Dave Cooper committed
16
  '(satisfies 3d-point-p)
17 18 19 20 21 22 23 24 25
  )

(deftype 3d-vector ()
  "Datatype 3d-vector is the result of a make-vector function using 3
  coordinates."
  '(satisfies 3d-vector-p)
  )

(defun 3d-point-p (point)
Dave Cooper's avatar
Dave Cooper committed
26 27
  "Boolean. 

28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
  FUNCTION
  3d-point-p - predicate function to check if a make-point is 3D.  That is, the
  point has 3 dimensions, representing a 3-dimensional point.

  USAGE
  3d-point-p point

  DESCRIPTION
  A predicate function to check if a point is 3-dimensional.

  The function may also be accessed by calling the function 3d-point?.

  EXAMPLES
  (3d-point-p (make-point 1 2 3))
  --> t

  (3d-point-p (make-point 1 2 3 4))
  --> nil
  "
Dave Cooper's avatar
Dave Cooper committed
47 48
  (and (arrayp point)
       (eq (array-total-size point) 3)
49 50 51
       (every #'(lambda(entry) (typep entry 'double-float)) point)))

(defun 3d-vector-p (vector)
Dave Cooper's avatar
Dave Cooper committed
52 53
  "Boolean. 

54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
  FUNCTION
  3d-vector-p - predicate function to check if a vector is 3D.  That is, the
  vector has 3 dimensions, representing a 3-dimensional vector. 

  USAGE
  3d-vector-p vector

  DESCRIPTION
  A predicate function to check if a vector is 3-dimensional.

  The function may also be accessed by calling the function 3d-vector?.

  EXAMPLES
  (3d-vector-p (make-vector 1 2 3))
  --> t

  (3d-vector-p (make-vector 1 2 3 4))
  --> nil
  "
Dave Cooper's avatar
Dave Cooper committed
73 74
  (and (arrayp vector)
       (eq (array-total-size vector) 3)
75
       (every #'(lambda(entry) (typep entry 'double-float)) vector)))