Jump to content

Hyperbolic Spirals


andregustavo

Recommended Posts

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) 
 )

Link to comment
Share on other sites

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)
 )

Link to comment
Share on other sites

  • 4 years later...

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!:unsure:

Link to comment
Share on other sites

A few spirals...

 

Logarithmic Spiral

 

LogSpiral.png

(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

 

HypSpiral.png

(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

 

ArchSpiral.png

(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

 

FermatSpiral.png

(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

 

LituusSpiral.png

(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)
)

Link to comment
Share on other sites

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?

code symbols.jpg

Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

Thanks for clarifying that Lee.

Makes sense.

I will look for a reference online that shows what html character equals what.

~Greg

Link to comment
Share on other sites

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

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...