- This wiki is out of date, use the continuation of this wiki instead
Cos
From FenixWiki
(Difference between revisions)
| Revision as of 00:19, 30 May 2007 (edit) Sandman (Talk | contribs) m ← Previous diff |
Revision as of 00:51, 8 June 2007 (edit) (undo) 130.89.160.132 (Talk) Next diff → |
||
| Line 5: | Line 5: | ||
| '''FLOAT''' cos ( <'''FLOAT''' angle> ) | '''FLOAT''' cos ( <'''FLOAT''' angle> ) | ||
| - | Returns the cosine of | + | Returns the cosine of the specified [[angle]]. |
| - | This [[function]] performs a cosine calculation on | + | This [[function]] performs a cosine calculation on the specified angle and returns the value as a [[floating point]] number between -1 and 1. |
| == Parameters == | == Parameters == | ||
| Line 18: | Line 18: | ||
| == Notes == | == Notes == | ||
| - | The [[angle]] value used in this | + | 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. |
| To read about all aspects of trigonometry, you can click on Wikipedia's [http://en.wikipedia.org/wiki/Trigonometric_function Trigonometric function] page. | To read about all aspects of trigonometry, you can click on Wikipedia's [http://en.wikipedia.org/wiki/Trigonometric_function Trigonometric function] page. | ||
| Line 24: | Line 24: | ||
| == Example == | == Example == | ||
| <pre> | <pre> | ||
| - | + | Program example_cos; | |
| - | + | Global | |
| float value; | float value; | ||
| - | + | Begin | |
| set_title("Cosine Graph"); | set_title("Cosine Graph"); | ||
| set_mode(825,480); | set_mode(825,480); | ||
| Line 47: | Line 47: | ||
| end | end | ||
| - | | + | Repeat |
| - | + | frame; | |
| - | | + | Until(key(_esc)) |
| - | + | ||
| - | + | ||
| + | End | ||
| + | </pre> | ||
| + | Used in example: [[set_title]](), [[set_mode]](), [[write]](), [[draw_line]](), [[put_pixel]](), [[key]]() | ||
| This will result in something like:<br /> | This will result in something like:<br /> | ||
| http://wwwhome.cs.utwente.nl/~bergfi/fenix/wiki/cos.PNG | http://wwwhome.cs.utwente.nl/~bergfi/fenix/wiki/cos.PNG | ||
Revision as of 00:51, 8 June 2007
Contents |
Definition
FLOAT cos ( <FLOAT angle> )
Returns the cosine of the specified angle.
This function performs a cosine calculation on the 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.
To read about all aspects of trigonometry, you can click on Wikipedia's Trigonometric function page.
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<360;angle++)
value=cos(angle*1000)*220;
put_pixel(angle*800/360,240+value,rgb(255,255,255));
end
Repeat
frame;
Until(key(_esc))
End
Used in example: set_title(), set_mode(), write(), draw_line(), put_pixel(), key()
This will result in something like:
