|
Trigonometric Functions:
The Cosine of a Value |
double cos(double x); long double cosl(long double x);
The cos() function calculates the cosine of a number.
Consider AB the length of A to B, also referred to as the hypotenuse.
Also consider AC the length of A to C which is the side adjacent to
point A. The cosine of the angle at point A is the ratio AC/AB. That is,
the ratio of the adjacent length, AC, over the length of the
hypotenuse,
AB:
The returned value, the ratio, is a double-precision number between –1 and 1.
|
|
Example: A form contains an Edit control named edtValue. After the user
has typed a value and presses Enter, the OnKeyPress event retrieves the
number typed in the edit box, calculates its cosine and displays it in
the same Edit control:
//---------------------------------------------------
------------------------ void __fastcall TForm1::edtValueKeyPress(TObject *Sender, char &Key) { if( Key == VK_RETURN ) { double Value = edtValue->Text.ToDouble(); double Cosinus = cos(Value); edtValue->Text = Cosinus; } } //---------------------------------------------------------------------------
|
Trigonometric Functions:
The Sine of a Value |
|
Trigonometric Functions: Tangents
|
The C/C++ tan Functions
|
double tan(double x); long double tanl(long double x);
The tan() function calculates the tangent of a number.
In geometry, consider AC the length of A to C. Also consider BC the length of B to C. The tangent is the result of BC/AC; that is, the ratio of BC over AC.
In geometry, consider AC the length of A to C. Also consider BC the length of B to C. The tangent is the result of BC/AC; that is, the ratio of BC over AC.
Example: A form contains an Edit control named edtValue. After the user has typed a value and presses Enter, the
OnKeyPress event retrieves the number typed in the edit box, calculates its tangent and displays the result in the same Edit control:
//--------------------------------------------------------------------------- void __fastcall TForm1::edtValueKeyPress(TObject *Sender, char &Key) { if( Key == VK_RETURN ) { double Value = edtValue->Text.ToDouble(); double Tangent = tan(Value); edtValue->Text = Tangent; } } //---------------------------------------------------------------------------
0 comments:
Post a Comment