Sun position
Sun position algorithm
|
instead-of-math.h - header to be included instead of math.h More...
Go to the source code of this file.
Functions | |
static void | sincos (double angle_rad, double *sinA, double *cosA) |
Calculates sine and cosine of an angle. More... | |
static double | normalize (double x, double range) |
Normalizes a cyclic double precision floating point variable x to the interval [0, range), assuming range is > 0. More... | |
instead-of-math.h - header to be included instead of math.h
This header needs to be included instead of the standard C library header math.h, in order to provide some routines that are missing or possibly missing from math.h. This header will include math.h for you.
The reason it must be included instead of math.h is a little obscure. One of the routines we want is the sincos() routine. Two versions of math.h actually do have it: The GNU C library does, and the Apple Clang library also has it, but under a different name.
The problem is, to gain access to the function, we need to include the appropriate incantation BEFORE including math.h if we are using the GNU C library, but we need to add definitions AFTER including math.h if we are using the Apple Clang library.
So use this header instead of math.h to look after this problem.
This header also provides the following missing function:
Copyright (c) 2020, David Hoadley vcrum All rights reserved. ble@ westn et.c om.au
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Definition in file instead-of-math.h.
|
inlinestatic |
Calculates sine and cosine of an angle.
Where the math library supports it, this is more efficient than calling sin()
and cos()
separately.
[in] | angle_rad | Angle whose sine and cosine is wanted (radian) |
[out] | sinA | sine of angle angle_rad |
[out] | cosA | cosine of angle angle_rad |
Definition at line 114 of file instead-of-math.h.
|
inlinestatic |
Normalizes a cyclic double precision floating point variable x to the interval [0, range), assuming range is > 0.
(If range is negative, this will normalize x to the interval (range, 0], but this is not the main use case for this function.)
[in] | x | The variable (e.g. an angle in degrees or radian) |
[in] | range | The range to normalize x to (e.g. 2Pi or 360.0). It must be non-zero. |
This function returns the same results as fmod()
for positive x and range. Where it differs is in its handling of negative values of x.
Definition at line 144 of file instead-of-math.h.