using CAL to get tan of radius ??

Discussion in 'AutoCAD' started by jclaidler, Aug 18, 2003.

  1. jclaidler

    jclaidler Guest

    I need to be able to figure out the tan of a radius.
    How can this be accomplished in lisp ??
     
    jclaidler, Aug 18, 2003
    #1
  2. 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
     
    Pierre Marcotte, Aug 18, 2003
    #2
  3. jclaidler

    BillZ Guest

    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
     
    BillZ, Aug 18, 2003
    #3
  4. jclaidler

    BillZ Guest

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

    Bill
     
    BillZ, Aug 18, 2003
    #4
  5. jclaidler

    jclaidler Guest

    oops.. that's what I need. The tangent of an angle. How would that lisp look ??
     
    jclaidler, Aug 18, 2003
    #5
  6. jclaidler

    BillZ Guest

    Hint:
    Read my second post....



    Bill
     
    BillZ, Aug 18, 2003
    #6
  7. jclaidler

    jclaidler Guest

    I'm trying that, and I can't get it to work.
     
    jclaidler, Aug 18, 2003
    #7
  8. jclaidler

    jclaidler Guest

    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.
     
    jclaidler, Aug 18, 2003
    #8
  9. jclaidler

    BillZ Guest

    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
     
    BillZ, Aug 18, 2003
    #9
  10. jclaidler

    jclaidler Guest

    I'm getting -0.133526 for the tan of 25. That doesn't seem right.
     
    jclaidler, Aug 18, 2003
    #10
  11. jclaidler

    randy benson Guest

    That's correct for 25 radians, hint hint.


    I'm getting -0.133526 for the tan of 25. That doesn't seem right.
     
    randy benson, Aug 18, 2003
    #11
  12. jclaidler

    jclaidler Guest

    I get 'unknown command' with this.
     
    jclaidler, Aug 18, 2003
    #12
  13. jclaidler

    BillZ Guest

    what release acad are you using?
     
    BillZ, Aug 18, 2003
    #13
  14. jclaidler

    Paul Turvill Guest

    Not in 2000i -- probably a custom function.
    ___
     
    Paul Turvill, Aug 18, 2003
    #14
  15. jclaidler

    BillZ Guest

    Thanks!
     
    BillZ, Aug 18, 2003
    #15
  16. jclaidler

    BillZ Guest

    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
     
    BillZ, Aug 18, 2003
    #16
  17. jclaidler

    Paul Turvill Guest

    (defun tand (d)
    (/ (sin (* (/ d 180.0) pi))(cos (* (/ d 180.0) pi)))
    )
    ___
     
    Paul Turvill, Aug 18, 2003
    #17
  18. jclaidler

    Mark Propst Guest

    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 Propst, Aug 18, 2003
    #18
  19. jclaidler

    BillZ Guest

    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
     
    BillZ, Aug 19, 2003
    #19
  20. jclaidler

    BillZ Guest

    You're welcome. \8^)c\\\>

    Bill
     
    BillZ, Aug 19, 2003
    #20
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.