; Hi my concept firstly to determine the offsets, transitions, tangent Xs Ys LT ST Øs Øc Es K value etc..
; check or measure the spiral,arc ,linear dimensions comparing to the parameters in order to understand & get the ideas
; (see the example "SCC demo.dwg")
; if we are clear about the concept then we could proceed next step making polylines :kewl:
;
; i hope this simple function could help with minimal input?
; Main function= (cloth dA RC LS) which input basic parameters: Deflections angle (degrees), Radius & Spiral length
; Then i applied in routine C:TEST
; Command: TEST
;19/05/14 hp
; just a little contribution
; (cloth dA RC LS)
; Regular spiral-circular-spiral fundamental elements
; Formulae Reference: JKR civil engineering road design standard
;Argument , real number
;dA (degrees)
;RC
;LS
;returns: list of curvilinear geometry parameters
(mapcar 'setvar '("lunits" "angbase" "angdir" "luprec") (list 2 (/ pi 2) 1 4)
)
(defun rtod (num) (* 180.0 (/ num pi)))
(defun dtor (num)(* pi (/ num 180.0)))
(defun tan (num) (if(equal (cos num) 0. 1e-10)(*(/ 180. pi)1e+16)(/ (sin num) (cos num)))) ;R1.0
;*note: In math, tan 90 degrees should return infinity. This tan just "by passes" up to max 1e+16.
; rename this "tan" if u have your original "tan" function.
(defun cloth (dA# RC LS / dAR dAR/2 DC# TC
LC EC TS QS# C# dAc# dAcR QC# XS YS QS
ALC LT ST K# P# q## TS# ES# TC# LC# EC#
A# dAcR
)
(setq
dAR (dtor dA#) ; radians
dAR/2 (/ dAR 2.)
DC# (/ 5729.578 RC)
QS# (/ (* LS DC#) 200.0)
QS (dtor QS#) ; radians
C# (/ (* 0.0031 (expt QS# 3.)) 3600.0)
dAc# (- dA# (* QS# 2.0))
dAcR (dtor dAc#) ; radians
QC# (- (/ QS# 3.0) C#)
XS (* LS
(+ (- (+ (- 1.0
(/ (expt QS 2.0) 10.0)
) ;-
(/ (expt QS 4.0) 216.0)
) ;+
(/ (expt QS 6.0) 9360.0)
) ;-
(/ (expt QS 8.0) 685440.0)
) ;+
) ;*
YS (* LS
(+ (- (+ (- (/ QS 3.0) (/ (expt QS 3.0) 42.0)) ;-
(/ (expt QS 5.0) 1320.0)
) ;+
(/ (expt QS 7.0) 75600.0)
) ;-
(/ (expt QS 9.0) 6894720.0)
) ;+
) ;*
ALC (/ XS (cos (dtor QC#)))
LT (- XS (/ YS (tan QS)))
ST (/ YS (Sin QS))
K# (- XS (* RC (sin QS)))
P# (- YS (* RC (- 1.0 (cos QS))))
q## (/ P# (cos dAR/2))
TS# (+ (* (+ RC P#) (tan dAR/2)) K#)
ES# (- (/ (+ RC P#) (cos dAR/2)) RC)
TC# (* (tan (/ dAcR 2.0)) RC)
LC# (/ (* dAc# Pi RC) 180.0)
EC# (- (/ RC (cos (/ dAcR 2.0))) RC)
A# (sqrt (* RC LS))
) ;end setq
(if (< LC# 0)
(Progn (Alert
"\nSpiral Overlaps?! Invalid curve data\nPlease retry..."
)
(setq LC# 0.0)
(exit)
)
(list DC# QS# QC# XS YS ALC LT ST TS# ES# K# P# q## A# dAc# TC# LC#
EC#)
)
) ; defun clothd data
(defun C:TEST nil
(if(member nil(list dA Radius LSpiral))
(setq dA 90. LSpiral 0.0 Radius 100.); sets default variables globally
)
(setvar "cmdecho" 0)
(setq *cancel* *error*)
(defun *error* (error:)
(if (or(= error: "Function cancelled")(= error: "quit / exit abort"))
(princ "*Cancel*")(princ (strcat "\n\; error: " error: )))
(setq *error* *cancel*
*cancel* nil)
(princ))
(Princ "\nRequires 3 Parameters: Deflection, Radius, Spiral length")
(princ)
(initget 7)
(setq dA (getreal
(strcat "\nDeflection Angle, <"(rtos dA )"> ")); Input angle in fractions degrees
)
(initget 7)
(setq Radius (getreal (strcat "Radius of the curve <"(rtos Radius )">. Input Rc : ")))
(initget 5)
(setq LSpiral (getreal (strcat "Length of spiral curve <" (rtos LSpiral )">. Input Ls : "))
)
(if(zerop LSpiral)(setq LSpiral (+ LSpiral 1e-15)))
(mapcar '(lambda (abbr val)
(princ (strcat abbr (rtos val )))
)
(list (strcat "\n\nIP Parameters"
"\n"(Chr 208)"A \t= " (rtos dA ) ; degrees
"\nRc \t= " (rtos Radius )
"\n----------------------"
"\nSpiral Curve"
"\n\nLs \t= " (rtos LSpiral )
"\nDc \t= ")
(strcat "\n" (chr 216) "s \t= ") ; degress
(strcat "\n" (chr 216) "c \t= ") ; degress
"\nXs \t= "
"\nYs \t= "
"\nLC \t= "
"\nLT \t= "
"\nST \t= "
"\nTs \t= "
"\nEs \t= "
"\nK \t= "
"\nP \t= "
"\nq \t= "
"\nA \t= "
(strcat "\n----------------------"
"\nInternal Circular"
"\n\n"
(Chr 208)
"A'\t= " ;degrees
)
"\nTc'\t= "
"\nLc'\t= "
"\nEc'\t= "
)
(cloth dA Radius LSpiral)
)
(textpage)
(princ)
); End of C:TEST