Game Development Reference
In-Depth Information
Figure 8.1
A plot of the sine and cosine functions.
The DrawGraph function takes in a function used to plot the graph and a color
that decides what color the graph will be. Sine and cosine are waveforms, and it's
easy to make interesting new wave forms by adding these waves together. A new
waveform function can be created by using an anonymous method. This code
snippet creates a graph that combines cosine and sine but scales the result down
by a half.
DrawGraph(delegate(double value)
{
return (Math.Sin(value) + Math.Cos(value)) *0.5;
}, new Color(0.5f, 0.5f, 1, 1));
Try the following snippet and observe the graph you get.
DrawGraph(delegate(double value)
{
return (Math.Sin(value) + Math.Sin(value + value))*0.5;
}, new Color(0.5f, 0.5f, 1, 1));
 
Search WWH ::




Custom Search