Author Topic: TAN function  (Read 1983 times)

0 Members and 1 Guest are viewing this topic.

Coder

  • Swamp Rat
  • Posts: 827
TAN function
« on: June 10, 2017, 01:19:19 PM »
Hello guys.

I am trying to find the tangent value of the angle 30.0 with Autolisp but it does not give the same value as in Calculator:

Code: [Select]
(defun tan (x)
  (/ (sin x) (cos x))
  )

My example in Autolisp:

Code: [Select]
(* (tan 30.0) 0.275) returns -> -1.76147 which is not correct and it must return: 0.158771324

Could anyone explain why?

Thanks in advance.

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: TAN function
« Reply #1 on: June 10, 2017, 01:30:57 PM »
sin/cos operate with radians.

Coder

  • Swamp Rat
  • Posts: 827
Re: TAN function
« Reply #2 on: June 10, 2017, 01:39:39 PM »
sin/cos operate with radians.

Wow thank you Lee. that solved the puzzle.  :wink:

dgorsman

  • Water Moccasin
  • Posts: 2437
Re: TAN function
« Reply #3 on: June 12, 2017, 10:10:27 AM »
Quick hint: virtually *all* programming that deals with trig uses radians rather than degrees.
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}

Coder

  • Swamp Rat
  • Posts: 827
Re: TAN function
« Reply #4 on: June 12, 2017, 12:15:56 PM »
Quick hint: virtually *all* programming that deals with trig uses radians rather than degrees.

Thanks for the constructive input.







Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: TAN function
« Reply #5 on: June 12, 2017, 12:57:44 PM »
Radians are the only meaningful measure of angle. Degrees are essentially arbitrary: there is no more reason to divide the circle into 360 than for its many factors; you could equally divide the circle into 400 and use Grads.