|
Measure-Based Functions: The Pi Constant
|
The letter п, also written as Pi, is a constant number used in various
mathematical calculations. Its approximate value is 3.1415926535897932.
The calculator of Windows represents it as
3.1415926535897932384626433832795. Borland had included its value in the
math.h library as M_PI 3.14159265358979323846.
A diameter is two times the radius. In geometry, it is written as 2R. In
C++, it is written as 2 * R or R * 2 (because the multiplication is
symmetric). The circumference of a circle is calculated by multiplying
the diameter to Pi, which is 2Rп, or 2 * R * п or 2 * R * Pi.
A radian is 2Rп/R radians or 2Rп/R rad, which is the same as 2п rad or 2 * Pi
rad.
To perform conversions between the degree and the radian, you can use the formula:
360˚ = 2п rad which is equivalent to 1 rad = 360˚ / 2п = 57.3˚
|
Measure-Based Functions:
Cycle To Radius Conversion |
Extended __fastcall CycleToRad(Extended Cycles);
The CycleToRad() function is used to convert the measurement of
an angle from radians to cycles. This function is equivalent to using
the formula
Radian = 2Pi * Cycle
Here is an example:
|
//--------------------------------------------------------------------------- #include <MATH.HPP> #include <vcl.h> #pragma hdrstop #include "Unit1.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TForm1::btnConversionClick(TObject *Sender) { Extended Cyc = StrToFloat(edtCycle->Text); Extended Rad = CycleToRad(Cyc); edtRadian->Text = FloatToStr(Rad); } //---------------------------------------------------------------------------
|
Measure-Based Functions:
Degrees To Radius Conversion |
Extended __fastcall DegToRad(Extended Degrees);
The DegToRad() function is used to calculate the equivalent value of an angle from degrees to radians. This function follows the formula:
2Pi rad = 360˚
which is
1 rad = 360˚ / 2Pi = 180˚ / Pi = 57.3˚
Here is an example:
//--------------------------------------------------------------------------- void __fastcall TForm1::btnConversionClick(TObject *Sender) { Extended Deg = StrToFloat(edtDegrees->Text); Extended Rad = DegToRad(Deg); edtRadians->Text = FloatToStr(Rad); } //---------------------------------------------------------------------------
|
Measure-Based Functions:
Radius To Cycle Conversion |
Extended __fastcall RadToCycle(Extended Radians);
The RadToCycle() function is used to convert the measurement of
an angle from radians to cycles. This function is equivalent to using
the formula
Cycle = Radian / 2Pi
Here is an example:
//--------------------------------------------------------------------------- void __fastcall TForm1::btnConversionClick(TObject *Sender) { Extended Rad = StrToFloat(edtRadian->Text); Extended Cyc = RadToCycle(Rad); edtCycle->Text = FloatToStr(Cyc); } //---------------------------------------------------------------------------
|
Measure-Based Functions:
Radius To Degrees Conversion |
Extended __fastcall RadToDeg(Extended Radians);
The RadToDeg() function is used to calculate the equivalent value of an angle from radians to degrees. This function applies the formula:
360˚ = 2 * Pi
which is
1˚ = 2 * Pi
Here is an example:
//--------------------------------------------------------------------------- void __fastcall TForm1::btnConversionClick(TObject *Sender) { Extended Rad = StrToFloat(edtRadians->Text); Extended Deg = RadToDeg(Rad); edtDegrees->Text = FloatToStr(Deg); } //---------------------------------------------------------------------------
0 comments:
Post a Comment