Generates a haversin series in accordance with the specified parameters.
GHAVERSIN(length, spacing, frequency, phase)
length |
- |
An integer, the length of the output series. |
spacing |
- |
A
real, the spacing (delta x) between each point on the |
frequency |
- |
Optional. A real, the frequency specified in cycles per second (Hertz). Defaults to 1. |
phase |
- |
Optional. A real, the phase specified in radians. Defaults to 0. |
A series.
W1: ghaversin(1000, 1/1000)
Generates 1000 samples of a 1 Hz haversin sampled at 1000 Hz.
W2: ghaversin(1000, 1/1000, 2.0, pi/3)
Same as above except the frequency is 2 Hz and the phase is π/3 radians.
The haversin function is defined as:
The formula used to generate y[n] for n = 1 to N is:
y[n] = 0.5 • (1 - cos(2π • frequency • spacing • (n-1) + phase))
TRIGNOMETRIC FUNCTION GENERATORS
[1] |
C. C. Robusto |
|
The Cosine-Haversine Formula |
|
The American Mathematical Monthly, 64(1), 1957 |
|
pp 38-40 |