using CAL to get tan of radius ??

jclaidler

Usenet Archive
Joined
Apr 30, 2003
Messages
185
Reaction score
0
I need to be able to figure out the tan of a radius.
How can this be accomplished in lisp ??
 
jclaidler said:
I need to be able to figure out the tan of a radius.
How can this be accomplished in lisp ??

tan(angle) = sin(angle)/cos(angle)
(both of these are valid lisp commands)

in lispese, that would be:
(setq tanangle (/ (sin yourangle) (cos your angle)))

Ciao bye flush
Dr fleau
 
How about:
1/2 chord length divided by the radius = sine of 1/2 included angle? (setq chrd (* chord length 0.5)) (setq rad (radius of arc)) (setq tangent_1 (/ (sin (* (asin (/ chrd rad)) 2.0))(cos (* (asin (/ chrd rad)) 2.0)))) >>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<< (defun asin (x)   (cond     ((equal x 1.0 1.0e-16)      (* pi 0.5)     )     ((equal x -1.0 1.0e-16)      (* pi -0.5)     )     ((< (abs x) 1.0)      (atan (/ x (sqrt (- 1.0 (* x x)))))     )     (T      (prompt "\n*ERROR* (abs x) > 1.0 from ASIN function\n")     )   ) )
  

Bill
 
Oh yeah,
This also includes (/ (sin of angle)(cos of angle)) = tangent of angle.

Bill
 
oops.. that's what I need. The tangent of an angle. How would that lisp look ??
 
I have a formula to calculate the length on an incline / decline of conveyor. What I need is to plug in the tangent of a user defined angle.
 
A tangent is the ratio of the opposite side to the adjacent side of a right triangle. So (/ opposite adjacent)= tangent, also (/ (sin ang)(cos ang)) = tangent. Just the opposite is true:
(atan (/ opposite adjacent))= angle in radians or
(atan tangent)= angle in radians.
Bill
 
That's correct for 25 radians, hint hint.

I'm getting -0.133526 for the tan of 25. That doesn't seem right.
 
Evidently (tand val)is a custom funtion that I do not know of. Unknown command sounds like a comman funtion error not a lisp error. I run R14 at this time and I have always used the dtr function that I posted. I place it at the top of my lisp file so it loads when the file loads. That way I can call dtr from the program. I have the full function in my acadr14.lsp so that it loads at the start of AutoCAD. >>>>> (defun dtr (a)    (* pi (/ a 180.0)) ) (princ)                                          ;converts radians to degrees (defun rtd (a)    (/ (* a 180.0) pi) ) (princ) <<<<<< That way you can convert user input into radians for your calculations and convert it back for screen prompts and such.
HTH

Bill
 
sorry for the confusion,
I assumed you already had a tan function since you posted you were getting a result that would be the tangent of 25 radians. those were, as Paul noted, just custom functions(since autolisp doesnt' have a tan function, any tan fucntion will be someone's custom implementation) I just showed that to indicate you needed to pass radians, not degrees to your function, (or implement a tan function that receives degrees as input like my example of "(tand x)" )

use a dtr fucntion to convert, I assume you have that?(degrees to radians)
 
Mark,
I'm glad you brought it up!
It's good to learn new things.
PT posted a tand function which I've added to my toolbox. I like radians better. Radians is much simpler and straight forward that degrees anyway. With degrees you need the minutes and seconds which can drive you nuts programmically.

Bill
 

Latest threads

Back
Top