;; | ---------------------------------------------------------------------------- ;; | GE_ApplyInterP ;; | ---------------------------------------------------------------------------- ;; | Function : Apply interpolation on a segment of points. ;; | ;; | Arguments: 'Seg' - List of points to be interpolated ;; | ;; | 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_ApplyInterP( Seg / ZStart ZEnd vlist nlist len Idx PrevPt pt fac CumD Z ) (setq ZStart (nth 2 Seg) ZEnd (nth 3 Seg) vlist (nth 4 Seg) len (GE_PlLen vlist nil T) nlist '() Idx 1 CumD 0.0 fac (/ (- ZEnd ZStart) len) ) (foreach pt vlist (if (= Idx 1) (setq nlist (cons (list (car pt) (cadr pt) ZStart) nlist)) (setq CumD (+ CumD (distance PrevPt pt)) Z (+ ZStart (* CumD fac)) nlist (cons (list (car pt) (cadr pt) Z) nlist) )) (setq PrevPt pt Idx (1+ Idx) ) ) (reverse nlist) )