# Trigonometric functions

Thread Starter

#### Art

Joined Sep 10, 2007
806
I found a Sunrise/Sunset algorithm here:
http://williams.best.vwh.net/sunrise_sunset_algorithm.htm
which gives step by step English explanation of what it is doing.
It uses sin, cos, tan, asin, acos & atan functions.

I have generated all the tables with a program and saved them as c arrays
in an effort to implement the needed trig function using lookup tables since
the platform I'm using doesn't have a maths lib.

Just to clarify...

sin, cos & atan should range from 0-360,

asin, acos & tan from 0 to 1.

Is that right?

#### DumboFixer

Joined Feb 10, 2009
217
I don't think so.

The angle has a range of 0 to 360 (assuming working with degrees and not radians). The sin and cos of the angle will range from -1 to +1. The tan of the angle can range from -infinity to +infinity.

sin(45) = 0.707

The input parameter for asin and acos should range from -1 to +1 whilst the imput parameter for atan can be anything.

The tan of a horizontal line is 0 and the tan of a vertical line is infinite.

Does this help ?

#### someonesdad

Joined Jul 7, 2009
1,583
Here's a plot of various elementary functions: http://www.gdssw.com/tools/ElementaryFunctions.pdf. I did this with python, matplotlib, and SciPy.

I recommend you do all trigonometric work in your programming in radians, even if you're doing it for an embedded system. I have seen many program errors where degrees get used where radians were meant (e.g., usually when dealing with a math library for a particular language) and vice versa. It can be hard to track down bugs caused by these types of mistakes.

Similar threads