andregustavo Posted August 24, 2006 Posted August 24, 2006 Hello All. I have been looking for a generic lisp routine for drawing an hiperbolic spiral and couldn't find it. However, Fuccaro has a script for a logarithmic spiral. Since I have no programing abilities, can the script be rewritten to work with the following equation r = a / alpha ? Thanks in advance This is Fuccaro's script for the logarithmic spiral ( r=a*exp(b*alpha)) ;|draw a logarithmic spiral Miklos Fuccaro [email="mfuccaro@hotmail.com"]mfuccaro@hotmail.com[/email] ---------------------August 2006-------|; (defun c:logsp( / a b a1 ori osmode cmdecho) ;a,b=curve paramethers ;a1 =angular increment ;ori=origin; set to the origin of the UCS (princ "logarithmic spiral R=a*exp(b*alpha)") (setq a (getreal "\na=") b (getreal "\tb=")) (setq a1 0.1 alpha (- a1) ori '(0 0 0)) (if (and a b) (progn (setq osmode (getvar "osmode") cmdecho (getvar "cmdecho")) (setvar "osmode" 0) (setvar "cmdecho" 0) (command "pline") (repeat 1000 ;nr of points (command (polar ori (setq alpha (+ alpha a1)) (* a (exp (* b alpha))))) ) (command "") (setvar "osmode" osmode) (setvar "cmdecho" cmdecho) ) (princ "Invalid input!") ) (princ) ) Quote
fuccaro Posted August 25, 2006 Posted August 25, 2006 Hello andregustavo and welcome in the forum! Here is the Lisp for the ecuation you wrote (r=a/alpha): (defun c:hipsp( / a a1 alpha osmode cmdecho) (setq a (getreal "\na= ") a1 0.1 alpha 0 osmode (getvar "osmode") cmdecho (getvar "cmdecho")) (mapcar 'setvar '("osmode" "cmdecho") '(0 0)) (command "pline") (repeat 500 (command (polar '(0 0 0) (setq alpha (+ alpha a1)) (/ a alpha)))) (command "") (mapcar 'setvar '("osmode" "cmdecho") (list osmode cmdecho)) (princ) ) Quote
leninne Posted May 22, 2011 Posted May 22, 2011 Hello Fuccaro! I saw your code regarding logarithmic spiral, I know it's a lisp code, but because i'm very new in this area I don't quite know to to create the lisp file in order to load it (I have seen other lisp files, they look different, that is why I am so confused). I need the code to create a spiral that will be placed in an antenna. Really really need your help! Quote
Lee Mac Posted May 22, 2011 Posted May 22, 2011 A few spirals... Logarithmic Spiral (defun c:LogSpiral ( / a0 i v p a b l ) (setq a0 0.0 ;; Start Angle i 0.1 ;; Increment v 500 ;; Vertices ) (princ "\nLogarithmic Spiral: r=ae^(b0)") (if (and (setq a (getreal "\nParameter a=")) (setq b (getreal "\nParameter b=")) (setq p (getpoint "\nBase Point: ")) ) (entmakex (append (list (cons 0 "LWPOLYLINE") (cons 100 "AcDbEntity") (cons 100 "AcDbPolyline") (cons 90 v) ) (repeat v (setq l (cons (cons 10 (polar p (setq a0 (+ a0 i)) (* a (exp (* b a0))))) l)) ) ) ) ) (princ) ) Hyperbolic Spiral (defun c:HypSpiral ( / a0 i v a p l ) (setq a0 0.0 ;; Start Angle i 0.1 ;; Increment v 500 ;; Vertices ) (princ "\nHyperbolic Spiral: r=a/x") (if (and (setq a (getreal "\nParameter a=")) (setq p (getpoint "\nBase Point: ")) ) (entmakex (append (list (cons 0 "LWPOLYLINE") (cons 100 "AcDbEntity") (cons 100 "AcDbPolyline") (cons 90 v) ) (repeat v (setq l (cons (cons 10 (polar p (setq a0 (+ a0 i)) (/ a a0))) l)) ) ) ) ) (princ) ) Archimedian Spiral (defun c:ArchSpiral ( / a0 i v p a b l ) (setq a0 0.0 ;; Start Angle i 0.1 ;; Increment v 500 ;; Vertices ) (princ "\nArchimedian Spiral: r=a+bx") (if (and (setq a (getreal "\nParameter a=")) (setq b (getreal "\nParameter b=")) (setq p (getpoint "\nBase Point: ")) ) (entmakex (append (list (cons 0 "LWPOLYLINE") (cons 100 "AcDbEntity") (cons 100 "AcDbPolyline") (cons 90 v) ) (repeat v (setq l (cons (cons 10 (polar p (setq a0 (+ a0 i)) (+ a (* b a0)))) l)) ) ) ) ) (princ) ) Fermat Spiral (defun c:FermatSpiral ( / a0 i v p l ) (setq a0 0.0 ;; Start Angle i 0.1 ;; Increment v 250 ;; Vertices ) (princ "\nFermat Spiral: r=+-0^0.5") (if (setq p (getpoint "\nBase Point: ")) (entmakex (append (list (cons 0 "LWPOLYLINE") (cons 100 "AcDbEntity") (cons 100 "AcDbPolyline") (cons 90 (* 2 v)) ) (repeat v (setq l (append (list (cons 10 (polar p (setq a0 (+ a0 i)) (- (sqrt a0))))) l (list (cons 10 (polar p (setq a0 (+ a0 i)) (sqrt a0)))) ) ) ) ) ) ) (princ) ) Lituus Spiral (defun c:LituusSpiral ( / a0 i v p l ) (setq a0 0.0 ;; Start Angle i 0.1 ;; Increment v 500 ;; Vertices ) (princ "\nLituus Spiral: r=0^-0.5") (if (setq p (getpoint "\nBase Point: ")) (entmakex (append (list (cons 0 "LWPOLYLINE") (cons 100 "AcDbEntity") (cons 100 "AcDbPolyline") (cons 90 v) ) (repeat v (setq l (cons (cons 10 (polar p (setq a0 (+ a0 i)) (/ 1. (sqrt a0)))) l)) ) ) ) ) (princ) ) Quote
troggarf Posted May 22, 2011 Posted May 22, 2011 Cool stuff Lee!! Quick question that is off topic but is illustrated in this post: What causes code symbols like parenthesis to lose its symbol and show its alpha-numeric code? I've run into this previously and don't want to decipher it. Any suggestions on how to fix this and avoid it? Quote
Lee Mac Posted May 22, 2011 Posted May 22, 2011 Thanks Greg I believe the html character substitution occurs when an old thread is archived, or perhaps it happened when a server was changed - that'd be a question for David. A quick find and replace will fix it Quote
troggarf Posted May 22, 2011 Posted May 22, 2011 Thanks for clarifying that Lee. Makes sense. I will look for a reference online that shows what html character equals what. ~Greg Quote
Lee Mac Posted May 22, 2011 Posted May 22, 2011 I will look for a reference online that shows what html character equals what. The numbers in the html character expressions are just the ASCII codes, hence: ( = ( Since (chr 40) = ( There are many ASCII references, I use this one mostly. For a HTML Special Character and ASCII reference, see the W3 Web Standards site here, and here. Lee Quote
fuccaro Posted May 22, 2011 Posted May 22, 2011 Thanks Lee, for coming earlier and posting the cure for my old routines. Have a nice day! Quote
Recommended Posts
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.