Author Topic: Need help to convert this equation.  (Read 2095 times)

0 Members and 1 Guest are viewing this topic.

HasanCAD

  • Swamp Rat
  • Posts: 1420
Need help to convert this equation.
« 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

HasanCAD

  • Swamp Rat
  • Posts: 1420
Re: Need help to convert this equation.
« Reply #1 on: May 21, 2012, 10:08:17 AM »
This is input
Code: [Select]
(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
Code: [Select]
(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)
     )

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: Need help to convert this equation.
« Reply #2 on: May 21, 2012, 10:13:04 AM »
You have to calculate the variables used in later calculations first.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

HasanCAD

  • Swamp Rat
  • Posts: 1420
Re: Need help to convert this equation.
« Reply #3 on: May 21, 2012, 11:33:43 AM »
You have to calculate the variables used in later calculations first.

Is it OK
Code: [Select]
(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)
)

HasanCAD

  • Swamp Rat
  • Posts: 1420
Re: Need help to convert this equation.
« Reply #4 on: May 21, 2012, 12:15:59 PM »
I got it

Thanks for help