PDA

View Full Version : Spiral and helix help

pintech
1st May 2005, 06:58 pm
Can anyone help me a little bit with spirals stuff?

Im trying to "mix" two codes:

This one:

(defun c:hely (/ cir cnt rin dis vol res alt azg rep dph azr dpv dhv snt rot)

;;; variáveis input ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;

(setq rin (getdist "\n initial radius (2 points or real number): "))
(setq dis (getdist "\n distance between laps (2 points or real number): "))
(setq vol (getint "\n number of laps: "))
(setq res (getint "\n number of segments that define the lap (resolution): "))
(setq alt (getdist "\n total height of the helicoidal (2 pontos ou nº real): "))
(setq azg (getreal "\n angle of the helicoidal with the axis zz in degrees(2points or real number): "))
(setq snt (getstring "\n the direction is clockwise,ccw or they are double helicoidals [cw/ccw/d]? "))
(setq ndh (getint "\n number of spirals: "))

;;; variables ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;

(setq cir (* 2 pi))

(setq rep (* res vol)) ;nº of repetions = nº of segments x nºof laps
(setq dph (/ dis res)) ;horizontal distance between two consecutives points = distance between laps / nº of segments per lap
(setq azr (* (/ azg 360) cir)) ;angle of the helicoidal axis with the zz axis
(setq div (/ cir ndh)) ;division of the circle by the number of helicoidals to draw
(setq dpv (/ alt rep)) ;vertical distance between two consecutive points =height / number of repetions
(setq dhv (/ (* (atan azr) alt) rep)) ;horizontal distance between two points of the helicoidal axis

(if (= snt "h") (setq rot -1) (setq rot 1))

;;; desenho 3dpoly ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;

(setq cth 0) ;helicoidal counter
(repeat ndh ;repeat the number of spirals

(setq cnt 0) ;segments counter
(repeat rep ;repeat segments

(command "3dpoly"
(polar (list (* dhv cnt) 0 (* dpv cnt))
(* rot (+ (* cnt (/ cir res)) (* div cth)))
(+ rin (* cnt dph))
)
(polar (list (* dhv (+ cnt 1)) 0 (* dpv (+ cnt 1))) ;reference point
(* rot (+ (* (+ cnt 1) (/ cir res)) (* div cth))) ;angle
(+ rin (* (+ cnt 1) dph)) ;distance to reference point
)

"");; end command 3dpoly

(setq cnt (+ cnt 1)) ; segments counter

);; fim repeat rep

(setq cth (+ cth 1)) ;spirals counter

);; fim repeat ndh

(command "zoom" "e");

);;função hely

And this one:

(defun C:Helcon()
(setq segs 20); segments/turn
(setq spin -1); -1=CW, 1=CCW
(initget (+ 1 4))
(setq h (getreal "elevation "))
(initget (+ 1 2 4))
(setq tu (getreal "turns "))
(setq old (getvar "osmode"))
(setvar "cmdecho" 0)
(setq fi1 (/ (* 2 PI) segs) i 0)
(setq points (fix (* tu segs))
h1 (/ h points) r1 (/ (- rf ri) points)
s (getpoint "center of base ")
(setvar "osmode" 0 )
(command "line" s end "")
(command "chprop" "l" "" "c" 1 "")
(command "3dpoly")
(setq i 0)
(repeat (1+ points)
(setq fi (* i fi1) h (* i h1) r (+ ri (* i r1)))
(setq x (* r (cos fi)) y (* spin r (sin fi)))
(command (list (+ (car s) x) (+ (cadr s) y) (+ (caddr s) h)))
(setq i (1+ i)))
(command "")
(setvar "osmode" old))

Actually i am trying to put in the second one the options :

Angle: (setq azg (getreal "\n angle of the helicoidal with the axis zz in degrees(2points or real number): "))

Spirals counter: (setq ndh (getint "\n number of spirals: "))

And i also trying to extrude a circle in the spirals path...

Are this things possible?
Can anyone give a big help?

Regards