PDA

View Full Version : arcsin


t-bone67
2005-05-12, 03:50 PM
Back to my circular stair routine. I've determined the math equation that will give me the angle of rotation on my steps. However, it includes arcsin, which is not a function in AutoLISP. Does anybody know how to use arcsin in an AutoLISP program?


Thanks in advance for your help.

RobertB
2005-05-12, 04:05 PM
I have some trig utils.

tflaherty
2005-05-24, 08:58 PM
OK, I got the trig routines you posted, but I'm unsure how to fit it into my code. The problem I need to solve is:

theta = (* 2 (arsin (/ 5.5 (+ isr 12))))

I attached the entire code for your reference, but here's the vital piece below. The first 2 lines are way wrong and that's where I need to do the above math equation.



(setq ang (sin (/ 5.5 (+ isr 12)))
rtang (* 2 ang))
(command "rotate" "last" "" cp rtang)
(princ)
) ;_ end of defun

CADmium
2005-05-24, 09:32 PM
a function , to get the arcsin of a value beetween -1 .. 1

(defun ASIN ( SINUS / WINKEL )
(if (numberp SINUS)
(cond
((= SINUS 1) (/ PI 2.0))
((= SINUS -1) (/ PI -2.0))
((and(<= SINUS 1.0)(>= SINUS -1.0))
(setq WINKEL (atan (/ SINUS (sqrt (- 1.0 (* SINUS SINUS))))))
)
)
)
)


for instance :
(rtos(asin 0.5)2 8 ) ->"0.52359878"
(sin 0.52359878 ) -> 0.5

hope it helps

Greetings from Germany
Thomas

RobertB
2005-05-25, 06:36 PM
OK, I got the trig routines you posted, but I'm unsure how to fit it into my code. The problem I need to solve is:

theta = (* 2 (arsin (/ 5.5 (+ isr 12))))

I attached the entire code for your reference, but here's the vital piece below. The first 2 lines are way wrong and that's where I need to do the above math equation.



(setq ang (sin (/ 5.5 (+ isr 12)))
rtang (* 2 ang))
(command "rotate" "last" "" cp rtang)
(princ)
) ;_ end of defunAll angles in Visual LISP need to be in radians. After you calc the angles in radians, convert them to degrees for command-line angles.

tflaherty
2005-05-25, 10:17 PM
OK, I understand that and I know how to fix it. But, my question is how do I take this piece from your trig.lsp file you sent me:

;;;Arcsine
(defun rrbI:ArcSin (x)
(cond ((= x 1.0) (/ pi 2.0))
((= x -1.0) (/ pi -2.0))
((< (abs x) 1.0) (atan (/ x (sqrt (- 1.0 (* x x))))))
((prompt (strcat "\n error: bad argument: " (rtos (abs x) 2) ">1.0\n ")))))

and call it in my routine.

I'm thinking it needs to look like this:

(setq x (/ 5.5 (+ 12 isr))
(setq a (rrbl:arcsin))

then multiple that answer by 2 and convert it to degrees.

Am I close.

Thanks for your help

kennet.sjoberg
2005-05-25, 11:54 PM
. . . and call it in my routine. . .
theta = (* 2 (arsin (/ 5.5 (+ isr 12))))
Set the theta as a lisp variable with the rrbl:ArcSin function like this :
(setq theta (* 2 (rrbI:ArcSin (/ 5.5 (+ isr 12 )))) )
: ) Happy Computing !

kennet