TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: HasanCAD on May 21, 2012, 09:56:10 AM
-
I tried to convert these equations to use in lisp but giving me diffident results than Excel.
Could some one help me to convert this equations to use in Lisp?
Thanks
-
This is input
(and (setq p1 (getpoint "\nPick first point."))
(setq p2 (getpoint p1 "\nPick second point."))
(setq *L* (cond ((getint
(strcat "\nWhat is HIGH Point <"
(itoa (setq *L* (cond ( *L* ) ( 160 )))) ">: "))) ( *L* )))
(setq *c* (cond ((getint
(strcat "\nWhat is LOW Point <"
(itoa (setq *c* (cond ( *c* ) ( 35 )))) ">: "))) ( *c* )))
)
(setq step 1000
dist (distance p1 p2)
#pt (fix (/ (/ dist step) 2))
ang (angle p1 p2)
pang (+ ang (/ pi 2.))
idx 1
)
Equation
(setq S (* 0.8 Dist);
X (* idx step)
a1 (/ (* (* (- *L* *c*) 0.1) Dist) (/ Dist 2));
ys1 (- *L* a1);
A (/ (- *c* ys1) (- (/ (* S S) 4) (/ (* S S)2)));
B (- 1 (* A S));
y (+ (+ (* A (* X X)) (* B X)) ys1)
yr (round y 5)
)
-
You have to calculate the variables used in later calculations first.
-
You have to calculate the variables used in later calculations first.
Is it OK
(setq Dst2 (/ Dist 2)
S (* 0.8 Dist)
SS (* S S)
SS2 (/ SS 2)
SS4 (/ SS 4)
S42 (- SS4 SS2)
X (* idx step)
XX (* X X)
XXA (* A XX)
XB (* B X)
XAB (+ XXA XB)
Lc (- *L* *c*)
Lc1 (* Lc 0.1)
LcD (* Lc1 Dist)
a1 (/ LcD Dst2)
ys1 (- *L* a1)
yc (- *c* ys1)
A (/ yc S42)
B (- (* A S))
y (+ XAB ys1)
yr (round y 5)
)
-
I got it
Thanks for help