;;; Some rough ideas about what the VMATH library might be
(in-package "VMATH")
;;; Scalar is the basic floating type.
(deftype scalar `single-float)
;;; This represents a packed (SIMD/Altivec) floating point vector of 4 components
(deftype vector4 `(simple-array scalar (4))
;;; Quaternions can be represented with the same structure of vector4
(deftype quat `vector4)
;;; XYZW Accessosrs
(defmacro x (v) (aref ,v 0))
(defmacro y (v) (aref ,v 1))
(defmacro z (v) (aref ,v 2))
(defmacro w (v) (aref ,v 3))
;;; Example
(defun v4add (va vb vr)
(declare (type vector4 va vb vr))
(setf (x vr) (+ (x va) (y va))
(y vr) (+ (y va) (y vb))
(z vr) (+ (z va) (z vb))
(w vr) (+ (w va) (z vb)))
vr)
;;; Which one sounds better:
;;;
;;; 1. V4+ ?
;;; 2. V4ADD ?
;;; 3. +V4 ?
;;; 4. ADDV4 ?
;;;
;;; My vote is for 2. More assembly like syntax.
;;; How to reduce the consing?
;;; Example:
;;; (sqrt some-value)
;;; That would cons, and more importantly is too generic
;;; (declare (type scalar some-value))
;;; (sqrt (the positive-scalar some-value))
;;; Would avoid consing on some of the Lisp Compilers
Blog of Dimiter "malkia" Stanev mainly for Common Lisp.
Sunday, August 05, 2007
Subscribe to:
Posts (Atom)
Blog Archive
-
►
2008
(1)
- ► 07/13 - 07/20 (1)
-
►
2005
(1)
- ► 07/10 - 07/17 (1)
-
►
2003
(5)
- ► 06/22 - 06/29 (2)
- ► 06/15 - 06/22 (3)