home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
vis-ftp.cs.umass.edu
/
vis-ftp.cs.umass.edu.tar
/
vis-ftp.cs.umass.edu
/
pub
/
Software
/
ASCENDER
/
ascendMar8.tar
/
UMass
/
BuildingFinder
/
Lisp
/
orientation.lisp
< prev
next >
Wrap
Lisp/Scheme
|
1995-04-12
|
4KB
|
111 lines
(in-package 'cme)
(defvar *tmpvec* (make-coordinate-vector 3))
(defun load-mb1 ()
(load "/home/rcde/RCDE_2.0/radius/model-board-1/mb1.site"))
(defun get-2d-image-world (idnum)
(cme::get-2d-world-named (format nil "MB1-j~d" idnum)))
(defun get-proj-matrix (world2d)
(ic::3d-to-2d-projection world2d))
(defun mb1-scale (lis)
(mapcar #'(lambda (p)
(list (* (/ 500 12.0) (car p))
(* (/ 500 12.0) (cadr p))
(* (/ 500 12.0) (caddr p))))
lis))
(defun project-truth (idnum x y z)
(let ((proj (3d-to-2d-projection (get-2d-image-world idnum))))
(setf (aref *tmpvec* 0) (coerce (* x (/ 500 12.0)) 'double-float))
(setf (aref *tmpvec* 1) (coerce (* y (/ 500 12.)) 'double-float))
(setf (aref *tmpvec* 2) (coerce (* z (/ 500 12.)) 'double-float))
(cme::project-vector proj *tmpvec* *tmpvec*)
(list (aref *tmpvec* 0) (aref *tmpvec* 1))))
(defun project-point (idnum x y z)
(let ((proj (3d-to-2d-projection (get-2d-image-world idnum))))
(setf (aref *tmpvec* 0) (coerce x 'double-float))
(setf (aref *tmpvec* 1) (coerce y 'double-float))
(setf (aref *tmpvec* 2) (coerce z 'double-float))
(cme::project-vector proj *tmpvec* *tmpvec*)
(list (aref *tmpvec* 0) (aref *tmpvec* 1))))
(defun backproject-point (idnum u v)
(let ((2dworld (get-2d-image-world idnum)))
(multiple-value-bind (x y z)
(project-to-world
(3d-to-2d-projection 2dworld)
(coerce u 'double-float)
(coerce v 'double-float)
(3d-world 2dworld))
(list x y z))))
(defun normalize2 (du dv)
(let ((len (sqrt (+ (* du du) (* dv dv)))))
(list (/ du len) (/ dv len))))
(defun image-corner-vectors (idnum u v)
(multiple-value-bind (x y z)
(values-list (backproject-point idnum u v))
(multiple-value-bind (ux vx)
(values-list (project-point idnum (+ 1.0 x) y z))
(multiple-value-bind (uy vy)
(values-list (project-point idnum x (+ 1.0 y) z))
(multiple-value-bind (uz vz)
(values-list (project-point idnum x y (+ 1.0 z)))
(list
(normalize2 (- ux u) (- vx v))
(normalize2 (- uy u) (- vy v))
(normalize2 (- uz u) (- vz v))))))))
;;
;; Added to allow projective camera model from the TEC images.
;;
;; Sept. 12, 1994
;; Christopher Jaynes
;;
(defun read-tec-projection (header-filename)
(MAKE-CAMERA-MODEL-FROM-TEC-HEADER
(read-1993-tec-image-header header-filename)))
(defun tec-project-point (projection x y z)
(setf (aref *tmpvec* 0) (coerce x 'double-float))
(setf (aref *tmpvec* 1) (coerce y 'double-float))
(setf (aref *tmpvec* 2) (coerce z 'double-float))
(cme::project-vector projection *tmpvec* *tmpvec*)
*tmpvec*)
(defun tec-backproject-point (projection u v zvalue)
(multiple-value-bind (x y z)
(project-to-world
projection
(coerce u 'double-float)
(coerce v 'double-float)
zvalue)
(setf (aref *tmpvec* 0) (coerce x 'double-float))
(setf (aref *tmpvec* 1) (coerce y 'double-float))
(setf (aref *tmpvec* 2) (coerce z 'double-float))
*tmpvec*))
(defun tec-image-corner-vectors (projection u v nominal-z-value )
(multiple-value-bind (x y z)
(values-list (tec-backproject-point projection u v nominal-z-value))
(multiple-value-bind (ux vx)
(values-list (tec-project-point projection (+ 1.0 x) y z))
(multiple-value-bind (uy vy)
(values-list (tec-project-point projection x (+ 1.0 y) z))
(multiple-value-bind (uz vz)
(values-list (tec-project-point projection x y (+ 1.0 z)))
(list
(normalize2 (- ux u) (- vx v))
(normalize2 (- uy u) (- vy v))
(normalize2 (- uz u) (- vz v))))))))