FLUENT - Easy way to compute distances and vector direction from graphics

Users have asked for an easy method to compute distances, vector components, and
unit vector starting from two points picked manually in FLUENT graphics window.
This Scheme function (cad-3.scm) allows the user to pick graphically two points in the FLUENT
graphics window and it computes (1) the vector defined by the points (2) the distance
between the two points (3) the unit vector for the vector.

; this is a comment in Scheme because it starts with a semi-colon
; all Scheme commands are contained between a pair of parenthesis

;; This Scheme file allows the user to define and measure
;; a direction and distance in FLUENT with two points picked
;; graphically on the screen

;; usage:
;; 1) File>Read>Scheme this file in FLUENT
;; 2) In the Fluent console window type
;; (graph2vec string1 string2)
;; where string1 and string2 are just names for the
;; two points defining the direction / distance
;; for example:

;; (graph2vec "A" "B")

;; then pick graphically the points A and B
;; with the right mouse button click (default)

;; do not change below this line without calling for support
(define pick-point
(lambda (prompt)
(cx-get-mouse-point prompt)))
(define point2vec
(lambda (point-a point-b)
(- (list-ref point-b 0)(list-ref point-a 0))
(- (list-ref point-b 1)(list-ref point-a 1))
(- (list-ref point-b 2)(list-ref point-a 2))
(define opwscal
(lambda (op arglist argscal)
(op (list-ref arglist 0) argscal)
(op (list-ref arglist 1) argscal)
(op (list-ref arglist 2) argscal)
(define magvec
(lambda (veclist)
(let ((vx)(vy)(vz))
(set! vx (list-ref veclist 0))
(set! vy (list-ref veclist 1))
(set! vz (list-ref veclist 2))
(sqrt (+ (* vx vx) (* vy vy) (* vz vz)))
(define graph2vec
(lambda (prompt-a prompt-b)
(let ((pa)(pb)(vab)(vunit)(magvab))
(display "n Point ")
(set! pa (pick-point prompt-a))
(display "=")
(display pa)
(display "nn Point ")
(set! pb (pick-point prompt-b))
(display "=")
(display pb)
(set! vab (point2vec pa pb))
(display "nn Vector AB =")
(display vab)
(set! magvab (magvec vab))
(format "nn Distance AB =~a" magvab)
(set! vunit (opwscal / vab magvab))
(display "nn Unit vector ab =")
(display vunit)

Show Form
No comments yet. Be the first to add a comment!