Trigonometric functions

Thread Starter


Joined Sep 10, 2007
I found a Sunrise/Sunset algorithm here:
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?


Joined Feb 10, 2009
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 ?


Joined Jul 7, 2009
Here's a plot of various elementary functions: 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.