home *** CD-ROM | disk | FTP | other *** search
- REM name: ptvector.cdl
-
- REM date: 091187 simon izraelevitz
-
- REM task: creates a point along a vector at a given distance
- REM from a base point
-
- REM -----------------------------------------------
-
- CLEAR
- dist = 1
- posopt = 2
-
- :ind_ln
- REM *** get vector line
- SET mask,2
- GETENT "Indicate vector line.", etype
- ON (@KEY + 3) GOTO exit,exit,
- p1wx = @FLTDAT[0]
- p1wy = @FLTDAT[1]
- p1wz = @FLTDAT[2]
- p2wx = @FLTDAT[3]
- p2wy = @FLTDAT[4]
- p2wz = @FLTDAT[5]
-
- REM *** compute unit vector in world coord.
- dx = p2wx - p1wx
- dy = p2wy - p1wy
- dz = p2wz - p1wz
- magn = sqrt(dx*dx + dy*dy + dz*dz)
- uwx = dx/magn
- uwy = dy/magn
- uwz = dz/magn
-
- REM *** map line to view coord.
- CALL xfwv,p1wx,p1wy,p1wz,p1vx,p1vy,p1vz
- CALL xfwv,p2wx,p2wy,p2wz,p2vx,p2vy,p2vz
-
- REM *** define line unit vector, view coord.
- dx = p2vx - p1vx
- dy = p2vy - p1vy
- dz = p2vz - p1vz
- magn = sqrt(dx*dx + dy*dy + dz*dz)
- uvx = dx/magn
- uvy = dy/magn
- uvz = dz/magn
-
- REM *** save cursor pick coordinates
- cr1x = @XCURSOR
- cr1y = @YCURSOR
-
- :get_dir
- REM *** get vector direction
- defopt =1
- GETPOS "Indicate direction",defopt
- ON (@KEY + 3) GOTO exit,ind_ln,get_dir,
- cr2x = @XCURSOR
- cr2y = @YCURSOR
-
- REM *** calculate projected distances from cursor picks
- REM to first end point of line
- dist1 = (cr1x - p1vx)*uvx + (cr1y - p1vy)*uvy
- dist2 = (cr2x - p1vx)*uvx + (cr2y - p1vy)*uvy
-
- REM *** define vector direction flag
- dir = (dist2 - dist1)/abs(dist2 - dist1)
-
- :get_pt
- REM *** get base point
- GETPOS "Indicate base point",posopt
- posopt = @KEY
- ON (@KEY + 3) GOTO exit,ind_ln,get_pt,
- pwx = @XWORLD
- pwy = @YWORLD
- pwz = @ZWORLD
-
- :get_dist
- REM *** get distance from base point
- GETFLT "Enter delta distance from base point (%f) =",dist,dist
- ON (@KEY + 3) GOTO exit,get_pt,
-
- REM *** point vector definition
- npx = pwx + dir*dist*uwx
- npy = pwy + dir*dist*uwy
- npz = pwz + dir*dist*uwz
- POINT npx,npy,npz
- GOTO get_pt
-
- :exit
- SET mask
- EXIT