Sine and Cosine waves

Description

Library for calculating sine and cosine waves.

The shape of the waves are configurable through the function parameters. Each time one of the functions is called the next value of the wave is calculated. A wave is separated into 360 steps.

OVERVIEW

SinCos_Abstract:
This library can be used to calculate sine and cosine waves. The shape of the waves are configurable through the function parameters. Each time one of the functions is called the next value of the wave is calculated. A wave is separated into 360 steps.

Interfaces: No hardware interface required
SinCos_How_to_use:
/* 1 sec. timer is used for the general program sequence */ #callback MainTimer() { new Float:fSin; // Current calculated value of the sine wave new Float:fCos; // Current calculated value of the cosine wave // Calculates the next value of the sine wave and isseus it wia the watch panel fSin = SinCurve(); #watch ("Sin = %f",fSin); // Calculates the next value of the cosine wave and isseus it wia the watch panel fCos = CosCurve(); #watch ("Cos = %f", fCos); } /* Application entry point */ main() { // Initialisation of a cyclic sec. timer setInterval(MainTimer, 1000); }

BASIC

Float:SinCurve(Float:fFrequency=1.0, Float:fScale=1.0, Float:fOffset=0.0, iStep=1)

The function calculates values for a sine wave. A call of the function calculates the next value of the wave.

fFrequency - Number of cycles (full sinusoidal wave) within the 360 steps
fScale - Peak-to-peak amplitude of the wave
fOffset - Zero offset of the wave (vertical shift)
iStep - Time distance (in steps) between the last calculated value and the current value to be calculated
returns : Float - Current calculated measurement value
Float:CosCurve(Float:fFrequency=1.0, Float:fScale=1.0, Float:fOffset=0.0, iStep=1)

The function calculates values for a cosine wave. A call of the function calculates the next value of the wave.

fFrequency - Number of cycles (full cosine wave) within the 360 steps
fScale - Peak-to-peak amplitude of the wave
fOffset - Zero offset of the wave (vertical shift)
iStep - Time distance (in steps) between the last calculated value and the current value to be calculated
returns : Float - Current calculated measurement value

On this page

Sine and Cosine waves