- This wiki is out of date, use the continuation of this wiki instead
Cos
From FenixWiki
(Difference between revisions)
Revision as of 15:48, 29 May 2007 (edit) G105b (Talk | contribs) ← Previous diff |
Revision as of 15:48, 29 May 2007 (edit) (undo) G105b (Talk | contribs) Next diff → |
||
Line 51: | Line 51: | ||
</pre> | </pre> | ||
- | + | This will result in something like:<br /> | |
+ | Image:http://wwwhome.cs.utwente.nl/~bergfi/fenix/wiki/cos.PNG |
Revision as of 15:48, 29 May 2007
Contents |
Definition
FLOAT cos ( <FLOAT angle> )
Returns the cosine of a specified angle.
This function performs a cosine calculation on a specified angle and returns the value as a floating point number between -1 and 1.
Parameters
FLOAT angle | - Angle, in thousandths of degrees. i.e. 75000 = 75º |
Returns
FLOAT : The cosine result of the specified angle.
Notes
The angle value used in this function should be in thousandths of degrees, as most angles within Fenix are, and will return a floating point value between -1 and 1.
Example
program example_cos; global float value; begin set_title("Cosine Graph"); set_mode(825,480); for(x=50;x<=800;x+=50) write(0,x,479,6,itoa(x*360/800)); end write(0,1,20,3,"1"); write(0,1,240,3,"0"); write(0,1,460,3,"-1"); draw_line(15,1,15,479); draw_line(1,470,824,470); for(angle=0;angle<360000;angle++) value=cos(angle*1000)*220; put_pixel(angle*800/360,240+value,rgb(255,255,255)); end repeat frame; until(key(_esc)) end
This will result in something like:
Image: