anchor.diff:  
   (in-package #:cl-3d)
   
  +;; ----------------------------------------------------------------------------
   (defun radians (x)
     (declare (single-float x))
     (* x (/ pi 180)))
   
  +;; ----------------------------------------------------------------------------
   (defun degrees (x)
     (declare (single-float x))
     (* x (/ 180 pi)))
  +
  +;; ----------------------------------------------------------------------------
  +(defun transform (translation center rotation scale scaleOrientation)
  +  (let ((C (sb-cga:translate center))
  +        (R (apply #'sb-cga:rotate-around rotation))
  +        (S (sb-cga:scale scale))
  +        (SR (apply #'sb-cga:rotate-around scaleOrientation))
  +        (Tx (sb-cga:translate translation)))
  +    (let ((-SR (sb-cga:inverse-matrix SR))
  +          (-C (sb-cga:inverse-matrix C)))
  +      (sb-cga:matrix* Tx C R SR S -SR -C))))
   
   ;; ----------------------------------------------------------------------------
   (defun frustum (xmin xmax ymin ymax znear zfar)
  
positive.code: (defmethod SFRotation ((vec cl:vector) &optional y (z NIL) (a NIL))
    (list vec (coerce y 'single-float)))
  
  ;; ---------------------------------------------------------------------SFVec2F
  ;; (defgeneric SFVec2F (x &optional y))
  
  ;; (defmethod SFVec2F(x &optional y)
  ;;   (SFVec2F (list x y)))
  
  ;; (defmethod SFVec2F((val cl:list) &optional (y NIL))
  ;;   (apply #'sb-cga:vec (mapcar (lambda (x)
  ;;                                (coerce x 'single-float))
  ;;                              val)))
  
  ;; ----------------------------------------------------------------------------
  (defgeneric SFVec3f (x &optional y z))
  
  (defmethod SFVec3F(x &optional y z)
    (SFVec3F (list x y z)))
  
  (defmethod SFVec3f ((str cl:string) &optional (y NIL) (z NIL))
    (let ((float-list (list<-str str)))
    (apply #'sb-cga:vec float-list)))
  
  (defmethod SFVec3F((val cl:list) &optional (y NIL) (z NIL))
    (apply #'sb-cga:vec (mapcar (lambda (x)
                                  (coerce x 'single-float))
                                val)))
  (defmethod SFVec3F((val cl:vector) &optional (y NIL) (z NIL))
    val)
  
  ;; ----------------------------------------------------------------------------
  (defun transform (translation center rotation scale scaleOrientation)
    (let ((C (sb-cga:translate center))
          (R (apply #'sb-cga:rotate-around rotation))
          (S (sb-cga:scale scale))
          (SR (apply #'sb-cga:rotate-around scaleOrientation))
          (Tx (sb-cga:translate translation)))
      (let ((-SR (sb-cga:inverse-matrix SR))
            (-C (sb-cga:inverse-matrix C)))
        (sb-cga:matrix* Tx C R SR S -SR -C))))
  
  ;; ----------------------------------------------------------------------------
  (defmethod SFRotation+ (a b)
    "Add the two rotations a b and returns new rotation a+b
  void sfrotation::add(sfrotation* r) {
     double tx = (r->x * r->angle) + (x * angle);
     double ty = (r->y * r->angle) + (y * angle);
     double tz = (r->z * r->angle) + (z * angle);
     angle = Math::Sqrt(tx*tx + ty*ty + tz*tz);
     if (angle == 0) {x=1;y=z=0;return;}
     x = tx/angle;
     y = ty/angle;
     z = tz/angle;
     }
  "
    (let ((vec-a (first a))
          (angle-a (second b))
          (vec-b (first b))
          (angle-b (second b)))
      (let ((va (sb-cga:vec* vec-a angle-a))
            (vb (sb-cga:vec* vec-b angle-b)))
        (let* ((v (sb-cga:vec+ vb va))
              (angle (sb-cga:vec-length v)))
          (if (= angle 0.0)
              (SFRotation 0.0 0.0 1.0 0.0)
              (SFRotation v angle))))))
  
  ;; ;; ----------------------------------------------------------------------------
  ;; (defmethod SFRotation-reorient (v1 v2)
  ;;   ""
  ;;   (let ((nv1 (sb-cga:normalize v1))
  ;;         (nv2 (sb-cga:normalize v2)))
  ;;     (print nv1)
  ;;     (print nv2)
  ;;     (if (sb-cga:vec~ nv1 nv2)
  ;;         (list (SFVec3f 0 0 1) (SFFloat 0.0))
  ;;         (let* ((vec (sb-cga:normalize (sb-cga:cross-product nv1 nv2)))
  ;;                (cross (sb-cga:dot-product nv1 nv2))
  ;;                (angle  (SFFloat (radians 1.0))))
  ;;                 ;(SFFloat (realpart (acos (sb-cga:dot-product nv1 nv2))))))
  ;;           (print vec)
  ;;           (print angle)
  ;;           (list vec angle)))))
  
  (defun trans<-matrix (mat)
    "Returns the translation component from matrix"
    (let ((m03 (sb-cga:mref mat 0 0))
          (m13 (sb-cga:mref mat 0 1))
          (m23 (sb-cga:mref mat 0 2)))
      (SFVec3F m03 m13 m23)))
  
  (defun rotate<-matrix(mat)
    "Takes a matrix and gives a SFRotation
  
  void SFMatrix::getSFRotation(SFRotation *rotation)
  
negative.code:               (- zfar znear)))
          (f (/ (* -2 znear zfar)
                (- zfar znear))))
      (sb-cga:matrix   a    0.0     c  0.0
                       0.0    b     d  0.0
                       0.0  0.0     e    f
                       0.0  0.0  -1.0  0.0)))
  
  ;; ----------------------------------------------------------------------------
  (defun perspective (fov aspect znear zfar)
    (let* ((ymax (SFFloat (* znear
                             (tan (radians (SFFloat (/ fov 2)))))))
           (ymin (- ymax))
           (xmin (* ymin aspect))
           (xmax (* ymax aspect)))
  