Jump to content

High to Low waves route


Jhun Gonzalo

Recommended Posts

Hi all,

 

Please to help me to have a Lisp route of Waves like shown on attached image,

 

On the length to be assigned numbers of bays and must be 50mm on distance every bays, then the width will be getting the distance by pt1 to pt2 to divide the distance according to the number of bays of length,:unsure:

 

The wave is like a sound measurement that like High to low frequency the graph dot lines will be the imaginarily path for the wave distance to show what it will be, Kindly if you have a route to create a wave please to have also, Thanks all

waves.jpg

Link to comment
Share on other sites

Not sure if this will help, it is very much incomplete but I toyed around with it a bit. It has an option for damped harmonic motion, perhaps you could change the variables therein to suit your needs.

 

That said, it's a lot of fun. I've also got code for a sphere and hyperbolic paraboloid, if you're interested.

 

The code itself is -not- complex, it is actually quite basic (nested repeats) so you can modify it easily with a core knowledge of LISP.

 

It's been a while so I'm not sure if you can directly set the frequency... but maybe it'll get the ball rolling at least.

 

That said, it's a lot of fun :3 Try creating your own functions for other formulae!

 

Hope it helps. ^^

 

; Function Plot
; by Mark Mercier

(defun c:fnplot(/ list1)

 ; Plot function
 (setq echo (getvar "cmdecho"))
 (setvar "cmdecho" 0)
 
 (setq lowerBnd 0.0000000
   upperBnd 10.0000000
   precisionX 2000
   precisionY precisionX
   results "hi"
   )
 (setq incrementX (/ (- upperBnd lowerBnd) precisionX))
 (setq incrementY (/ (- upperBnd lowerBnd) precisionY))

 (setq dum1 lowerBnd)
 (repeat precisionX ; Begin repeat loop
   (setq x dum1)
   (setq dum2 lowerBnd)
   (repeat precisionY ; Begin nested repeat loop
     (setq y dum2)

     (sinusoid x)
     ;(logarithm x)
     ;(dampedvibration x)
     ;(polynom x)
     
     (wheel)
     (setq dum2 (+ dum2 incrementY))
     ); /nested repeat
   (setq dum1 (+ dum1 incrementX))
   ); /repeat

 (if list1
   (scribblescribble)
   )
 
 (setvar "cmdecho" echo)
 (princ)
 ); /program

; -- Cheap error function
(defun goodtimes()
 (princ "Strong Bad, help! I swallowed a bug! The good times are over!")(princ)
 )

; -- Wheel function for spinnyness --
(defun wheel ()
(if (not wh)(setq wh "-"))
(cond
((= wh "|") (setq wh "/"))
((= wh "/") (setq wh "-"))
((= wh "-") (setq wh "\\"))
((= wh "\\") (setq wh "|"))
)
(prompt (strcat "\10" wh))
(princ)
)

; Line Sinusoid
(defun sinusoid(x /)
 (setq precisionY 1)
 
 (setq y_sinusoid (* 2 (sin x)))
 (setq list1 (append list1 (list (list x y_sinusoid 0))))
 )

; Line Polynomial
(defun polynom(x /)
 (setq precisionY 1)
 
 (setq consList (list 7 5 4 6 4 2 8 6 5 5 2))
 
 (setq y_polynom 0)
 (setq dumVar 0)
 (repeat (- (length consList) 1)
   (setq y_polynom (+ y_polynom (* (nth dumVar consList) (expt x (- (- (length consList) 1) dumVar)))))
   (setq dumVar (+ 1 dumVar))
   )
 (setq y_polynom (+ y_polynom (nth (- (length consList) 1) consList)))
 
 (setq list1 (append list1 (list (list x y_polynom 0))))
 )

; Line Damped Vibration
(defun dampedvibration(x /)
 (setq precisionY 1)
 (setq time x)

 ; Set up initial conditions for forced, underdamped response (0 < zeta < 1)
 (setq mass 1)                                ; m
 (setq damping_coeff 0)                        ; c        If 0, undamped
 (setq spring_const 2)                            ; k
 
 (setq initDis 1)                            ; x_o
 (setq initVel 0)                            ; v_o
 (setq initFor 10)                            ; F_o        If 0, free response
 
 (setq dampRat (/ damping_coeff (* 2 (sqrt (* spring_const mass)))))    ; zeta

 ; * Zeta must be greater than zero but less than one to proceed * ;
 (if (and (>= dampRat 0) (< dampRat 1))
   (progn
     ; Determine minor variables from initial conditions
     (setq modinitFor (/ initFor mass))                    ; f_o
 
     (setq drivFreq 1.1)                                ; omega
 
     (setq natFreq (sqrt (/ spring_const mass)))                ; omega_n
     (setq dampednatFreq (sqrt (- 1 (* natFreq dampRat dampRat))))        ; omega_d

     ; Determine major variables from minor variables

     (setq omn2_om (- (expt natFreq 2) (expt drivFreq 2)))
     (setq 2zomnom (* 2 dampRat natFreq drivFreq))
     (setq coefX (/ modinitFor (sqrt (+ (expt omn2_om 2) (expt 2zomnom 2)))))
     (setq theta (atan (/ 2zomnom omn2_om)))
     (setq XcosTheta (* coefX (cos theta)))
     (setq phiNum (* dampednatFreq (- initDis XcosTheta)))
     (setq phiDen (+ initVel (* natFreq dampRat (- initDis XcosTheta)) (* -1 drivFreq coefX (sin theta))))
     (if (and (= damping_coeff 0) (= initVel 0))    ; Test if undamped
       (setq phi 0)                    ; If undamped, set phi to zero
   (setq phi (atan (/ phiNum phiDen)))        ; Otherwise
      )
     (setq coefA (/ (- initDis XcosTheta) (sin phi)))
     (setq expo (expt 2.71828183 (* -1 dampRat dampednatFreq time)))

     ; Use major and minor variables to assemble general response function x(t)
     (setq dampingTerm (* coefA expo (sin (+ (* dampednatFreq time) phi))))
     (setq forcingTerm (* coefX (cos (- (* drivFreq time) theta))))

     ; Final response
     (setq y_dampedvibe (+ dampingTerm forcingTerm))
 
     (setq list1 (append list1 (list (list x y_dampedvibe 0))))
     )
   (progn
     )
   )
 )

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...