;; | ---------------------------------------------------------------------------- ;; | GE_Interpolate ;; | ---------------------------------------------------------------------------- ;; | Function : Interpolate all zero value coordinates between two non-zero ;; | values ;; | ;; | Arguments: 'vlist' - List of points to be interpolated ;; | 'fuzz' - Fuzz factor to be considered for 0.0 elevation ;; | ;; | Returns : 'vlist' - The list of interpolated points ;; | ;; | Comments: Interpolation is the process of populating zero values lying in ;; | between two known non-zero values by arriving at these values by ;; | means of a process of linear interpolation. By this, it means that ;; | all the intermediate values are obtained by applying a uniform ;; | rate of change based on distance from the first of the two points ;; | forming the interpolation boundary. ;; | Theory: If A and B are two non-zero elevation points, ;; | A= x1, y1, z1 ;; | B= x2, y2, z2 ;; | and the distance between then is D, ;; | then linear interpolation is at any point in between is calculated ;; | at the rate of (Z2-Z1)/D per unit change of elevation from A ;; | e-mail : rakesh.rao@4d-technologies.com ;; | Web : www.4d-technologies.com ;; | ---------------------------------------------------------------------------- (defun GE_Interpolate ( vlist fuzz / pt cnt nlist _VxLst Z ZStart ZEnd VxStart VxEnd tmp Seg nverts Idx InRec len VxLst ) (setq nverts (length vlist) nlist '() VxLst '() VxStart nil VxEnd nil InRec nil Idx 1 ) (foreach pt vlist (setq Z (caddr pt) pt (list (car pt) (cadr pt) 0.0) ) (if (not (equal Z 0.0 fuzz)) (progn (setq InRec T nlist (cons pt nlist) ) (if (not VxEnd) (progn (setq VxEnd Idx nlist (reverse nlist) ZEnd Z ) (if (> (length nlist) 1) (setq VxLst (cons (list (if (not VxStart) 1 VxStart) VxEnd (if (not ZStart) 0.0 ZStart) ZEnd nlist ) VxLst ) )) (setq VxStart VxEnd ZStart ZEnd VxEnd nil nlist (list pt) ) )) ) (setq nlist (cons pt nlist)) ) (setq Idx (1+ Idx)) ) (if (> (length nlist) 1) (setq nlist (reverse nlist) VxEnd (1- Idx) ZEnd Z VxLst (cons (list (if (not VxStart) 1 VxStart) VxEnd (if (not ZStart) 0.0 ZStart) ZEnd nlist ) VxLst ) )) (setq VxLst (reverse VxLst)) (setq vlist '()) (foreach Seg VxLst (setq VxStart (nth 0 Seg) VxEnd (nth 1 Seg) ZStart (nth 2 Seg) ZEnd (nth 3 Seg) ) (if (and (not (zerop ZStart)) (not (zerop ZEnd)) ) (progn (setq Seg (GE_ApplyInterP Seg)) (if (>= (setq len (length Seg)) 2) (progn (if (not vlist) (setq vlist Seg) (setq vlist (append vlist (cdr Seg))) ) )) ) (progn (setq Seg (nth 4 Seg) pt (nth 0 Seg) pt (list (car pt) (cadr pt) ZStart) Seg (LI_RepList Seg 1 pt) Idx (1- (length Seg)) pt (nth Idx Seg) pt (list (car pt) (cadr pt) ZEnd) Seg (LI_RepList Seg (1+ Idx) pt) ) (if (not vlist) (setq vlist (append vlist Seg)) (setq vlist (append vlist (cdr Seg))) ) ) ) ) vlist )