Вы находитесь на странице: 1из 4

Content-Type: text; name="clotoide.

lsp"
Content-Transfer-Encoding: 8bit
Content-Disposition: inline; filename="clot.lsp"
;Listado 1. Programa CLOTOIDE.LSP (vlO+)
(defun factor (y)
(cond ((= 0.0 y) 1.0)
(t (* y (factor (1- y))))
)
)
;---------------------------------------(defun datos ()
(setq A nil R nil L nil)
(while (or
(and (= A nil)(= R nil))
(and (= A nil)(= L nil))
(and (= R nil)(= L nil)))
(textscr)
(terpri)(Princ "Clculo de la Clotoide entre recta y arco")
(terpri)(princ "_______________________________")
(terpri)(Princ "Introduccin de datos")
(terpri)(Princ "______________________________")
(terpri)
(initget (+ 2 4))
(setq A (getreal "Parmetro de la Clotoide [A]: "))
(initget (+ 2 4))
(setq R (getreal "Radio del Arco [R]: "))
(if (or (= A nil) (= R nil))
(progn
(initget (+ 2 4))
(setq L (getreal "Longitud de la Clotoide [L]: "))))
)
(if (= A nil) (setq A (sqrt (* R L))))
(if (= R nil) (setq R (/ (expt A 2.0) L)))
(if (= L nil) (setq L (/ (expt A 2.0) R)))
(initget (+ 1 2 4))
(setq pt (getint "Nmero de puntos a calcular [ ]: "))
(setq LL 0.00)
)
;---------------------------------------------------------(defun calculo (/ K X2 X3 X4 X5 X6 Yl Y2 Y3 Y4 Y5 Y6 xx yy)
(setq L
(+ L LL))
(setq Tt (/ L (* 2.0 R)))
(setq K
(* 2.0 (expt A 2.0)))
(setq
(setq
(setq
(setq
(setq

X2
X3
X4
X5
X6

(/
(/
(/
(/
(/

(expt
(expt
(expt
(expt
(expt

L
L
L
L
L

5.0)
9.0)
13.0)
17.0)
21.0)

(*
(*
(*
(*
(*

5.0 (factor 2.0)(expt K 2.0))))


9.0 (factor 4.0)(expt K 4.0))))
13.0 (factor 6.0)(expt K 6.0))))
17.0 (factor 8.0) (expt K 8.0))))
21.0 (factor 10.0)(expt K 10.0))))

(setq
(setq
(setq
(setq
(setq
(setq

Yl
Y2
Y3
Y4
Y5
Y6

(/
(/
(/
(/
(/
(/

(expt
(expt
(expt
(expt
(expt
(expt

L
L
L
L
L
L

3.0)
7.0)
11.0)
15.0)
19.0)
23.0)

(*
(*
(*
(*
(*
(*

3.0 K)))
7.0 (factor
11.0 (factor
15.0 (factor
19.0 (factor
23.0 (factor

3.0) (expt K 3.0))))


5.0)(expt K 5.0))))
7.0)(expt K 7.0))))
9.0)(expt K 9.0))))
11.0)(expt K 11.0))))

(setq X (- (+ (- (+ (- L X2) X3) X4) X5) X6))


(setq Y (- (+ (- (+ (- Yl Y2) Y3) Y4) Y5) Y6))
(setq Ap (atan (/ Y X)))
(setq Cp (expt (+ (expt X 2.0) (expt Y 2.0)) 0.5))
(setq Xo (- X (* R (sin Tt))))
(setq
(setq
(setq
(setq
(setq
(setq
(setq
(setq
)

Rt
Tc
Tl
Ft
Ct
xx
yy
xy

(- Y (* R (- 1.0 (cos Tt)))))


(/ Y (sin Tt)))
(- X (/ Y (/ (sin Tt) (cos Tt)))))
(list X Y))
(list Xo (+ Rt R)))
(rtos x 2 15))
(rtos y 2 15))
(strcat xx "," yy))

;-----------------------------------------------------------------(defun presenta ()
(terpri)(princ "Clculo de la Clotoide entre recta y arco")
(terpri)(princ "_____________________")
(terpri)(Princ "Datos introducidos")
(terpri)(Princ "________________________")
(terpri)(princ "Parmetro de la Clotoide [A]: ") (princ A)
(terpri)(Princ "Longitud de la Clotoide [L]: ") (princ L)
(terpri)(Princ "Radio del Arco [R]: ") (princ R)
(terpri)(Princ "Numero puntos a calcular [ ]: ")(princ Pt)
(terpri)
(terpri)(Princ "Datos del clculo") (terpri)
(princ "_______________")
(princ "\nCoordenada origen Clotoide[X,Y]: ") (princ "0.00,0.00")
(princ "\nCoordenada final Clotoide [XY]: ") (princ X)(Princ ",")(Princ Y)
(princ "\nAngulo de las Tangentes

[Tt]: ")(princ Tt)

(princ "\nAngulo Polar

[Ap]: ")(princ Ap)

(princ "\nCuerda Polar

[Cp]: ")(princ Cp)

(princ "\nAbscisa Centro Crculo


(princ "\nRetranqueo
(princ "\nTangente Corta

[Xo]: ")(princ Xo)


[Rt]: ")(princ (abs Rt))
[Tc]: ")(princ Tc)

(princ "\nTangente Larga


[Tl]: ")(princ Tl)(terpri)
(terpri)(terpri)
(terpri)
)
;----------------------------------------------------------------------------(defun dibujo()
(setq LL (/ L pt) L 0.00)
(command "_PLINE" "0.00,0.00")
(repeat pt
(calculo)
(command xy)
)
(command)
(command "_LINE" "0.00,0.00" (list Tl 0.00) "")
(command "_LINE" (list Tl 0.00) Ft "")
(command "_LINE" Ct Ft "")
(command "_POINT" "0,0")
(command "_POINT" Ct)
(command "_CIRCLE" Ct R)
(command "_POINT" Ft)
)
;*******************************************************************
(defun C:CLOTOIDE (/ osm pto pds aun aup lun lup opc res x y A R L LL Tt Ap Cp X
o Rt Lc Tl Ct xy pt)
;salvar variables
;(setq osm (getvar "OSMODE")) (setvar "OSMODE"
;(setq pto (getvar "PDMODE")) (setvar "PDMODE"
;(setq pds (getvar "PDSIZE")) (setvar "PDSIZE"
;(setq aun (getvar "AUNITS")) (setvar "AUNITS"
;(setq aup (getvar "AUPREC")) (setvar "AUPREC"
;(setq lun (getvar "LUNITS")) (setvar "LUNITS"
;(setq lup (getvar "LUPREC")) (setvar "LUPREC"
(textscr) (datos) (calculo)
(textscr) (presenta)
(setq res T)
(while res
(initget "Modificar Continuar")
(setq opc (getkword "Modificar/: "))
(if (= opc "Modificar")
(progn
(textscr) (datos)
(calculo) (textscr)
(presenta)
)
(progn
(terpri)(setq res nil)

0)
3)
-4)
2)
8)
2)
8)

(graphscr)
(command "_ZOOM" "_W" "-10.0,-10.0" (list (+ x 10)(+ y 10)))
)
)
(grclear)
(dibujo)

)
;restaurar variables
;(setvar "OSMODE" osm)
;(setvar "PDMODE" pto)
;(setvar "PDSIZE" pds)
;(setvar "AUNITS" aun)
;(setvar "AUPREC" aup)
;(setvar "LUNITS" lun)
;(setvar "LUPREC" lup)
(princ)
)

Вам также может понравиться