SophiaFramework UNIVERSE 5.3 |
The SFXTrigonometric class performs high-speed trigonometric calculation using the trigonometric table.
First of all, create the trigonometric table with the n equal parts of the radian section [0, FLOAT64_PI / 2] and their corresponding cosine values using the SFXTrigonometric::Initialize function. (FLOAT64_PI: the ratio of the circumference of a circle to its diameter)
And then, quickly calculate the cosine, sine, or tangent for the specified angle in radians using the SFXTrigonometric::Cos, SFXTrigonometric::Sin, or SFXTrigonometric::Sin function. In these functions, the above trigonometric table is internally used.
Trade-off of between calculation frequency and performance | |
---|---|
In general, trigonometric functions usually take much time. When trigonometric functions are frequently called, performance might be improved by using the SFXTrigonometric class. |
Trade-off of between calculation accuracy and memory consumption | |
---|---|
Calculation accuracy is improved as the number of the equal parts of the radian section [0, FLOAT64_PI / 2] increases. And the values which the trigonometric table contains also increases. Therefore heap memory will be needed all the more. (The consumption of heap memory is N * 8 bytes, where N is the number of the equal parts of the radian section [0, FLOAT64_PI / 2].) |
Create the trigonometric table by with the 180 equal parts of the radian section [0, pi / 2], and perform high-speed trigonometric calculation.
Float64 x, y; Float64 e = 1.0e-10; // asymptotic accuracy Float64 pi = 3.14159265358979; // the ratio of the circumference of a circle to its diameter SFXTrigonometric tri; tri.Initialize(180, e); // initialize trigonometric table x = tri.Cos(pi / 3); y = tri.Sin(pi / 3);
Constructor/Destructor |
---|
SFXTrigonometric( Void ) Constructor of the SFXTrigonometric class.
|
~SFXTrigonometric( Void ) Destructor of the SFXTrigonometric class.
|
Public Functions | |
---|---|
Float64 |
Cos(
Float64 param
) Calculate the cosine of a specific angle in radians.
|
static Float64 |
DegreeToGradian(
Float64 param
) Convert a specific angle in degrees to an angle in gradians.
|
static Float64 |
DegreeToRadian(
Float64 param
) Convert a specific angle in degrees to an angle in radians.
|
static Float64 |
GradianToDegree(
Float64 param
) Convert a specific angle in gradians to an angle in degrees.
|
static Float64 |
GradianToRadian(
Float64 param
) Convert a specific angle in gradians to an angle in radians.
|
SFCError |
Initialize(
SInt16 division = 90
) Initialize the trigonometric table.
|
static Float64 |
RadianToDegree(
Float64 param
) Convert a specific angle in radians to an angle in degrees.
|
static Float64 |
RadianToGradian(
Float64 param
) Convert a specific angle in radians to an angle in gradians.
|
Float64 |
Sin(
Float64 param
) Calculate the sine of a specific angle in radians.
|
Float64 |
Tan(
Float64 param
) Calculate the tangent of a specific angle in radians.
|
Void |
Terminate( Void ) Destroy the trigonometric table.
|
[ public, explicit ] SFXTrigonometric(Void);
To create a trigonometric table, call the SFXTrigonometric::Initialize function.
Note | |
---|---|
No trigonometric table is generated in this constructor. |
[ public ] ~SFXTrigonometric(Void);
Heap memory used by the trigonometric table is released.
The SFXTrigonometric::Cos function calculates the cosine of an angle in radians using the trigonometric table.
Note | |
---|---|
The trigonometric table needs to be created using the SFXTrigonometric::Initialize function before calling the SFXTrigonometric::Cos function. |
Float64 c; SFXTrigonometric tri; tri.Initialize(); // initialize trigonometric table c = tri.Cos(FLOAT64_PI); // c = -1;
SFXTrigonometric::RadianToGradian | SFXTrigonometric::RadianToDegree | SFXTrigonometric::GradianToRadian | SFXTrigonometric::GradianToDegree | SFXTrigonometric::DegreeToRadian
Float64 n = SFXTrigonometric::DegreeToRadian(180); // n = 3.1415...
SFXTrigonometric::RadianToGradian | SFXTrigonometric::RadianToDegree | SFXTrigonometric::GradianToRadian | SFXTrigonometric::GradianToDegree | SFXTrigonometric::DegreeToGradian
SFXTrigonometric::RadianToGradian | SFXTrigonometric::RadianToDegree | SFXTrigonometric::GradianToRadian | SFXTrigonometric::DegreeToRadian | SFXTrigonometric::DegreeToGradian
SFXTrigonometric::RadianToGradian | SFXTrigonometric::RadianToDegree | SFXTrigonometric::GradianToDegree | SFXTrigonometric::DegreeToRadian | SFXTrigonometric::DegreeToGradian
Specify the number of the equal parts of the radian section [0, FLOAT64_PI / 2] The greater the value of this parameter, the larger the consumption of heap memory.
The SFXTrigonometric::Initialize function creates the trigonometric table for performing high-speed trigonometric calculation.
Notes | |
---|---|
The SFXTrigonometric::Initialize function destroys the previous trigonometric table. |
Execute the SFXTrigonometric::Initialize function immediately after the constructor is called.
SFXTrigonometric tri; tri.Initialize(180);
Float64 n = SFXTrigonometric::RadianToDegree(6.2831); // n = 359.99...
SFXTrigonometric::RadianToGradian | SFXTrigonometric::GradianToRadian | SFXTrigonometric::GradianToDegree | SFXTrigonometric::DegreeToRadian | SFXTrigonometric::DegreeToGradian
SFXTrigonometric::RadianToDegree | SFXTrigonometric::GradianToRadian | SFXTrigonometric::GradianToDegree | SFXTrigonometric::DegreeToRadian | SFXTrigonometric::DegreeToGradian
The SFXTrigonometric::Sin function calculates the sine of an angle in radians using the trigonometric table.
Note | |
---|---|
The trigonometric table needs to be created using the SFXTrigonometric::Initialize function before calling the SFXTrigonometric::Sin function. |
Float64 c; SFXTrigonometric tri; tri.Initialize(); // initialize trigonometric table c = tri.Sin(FLOAT64_PI / 2); // c = 1;
The SFXTrigonometric::Tan function calculates the tangent of an angle in radians using the trigonometric table.
Note | |
---|---|
The trigonometric table needs to be created using the SFXTrigonometric::Initialize function before calling the SFXTrigonometric::Tan function. |
Float64 c; SFXTrigonometric tri; tri.Initialize(); // initialize trigonometric table c = tri.Tan(FLOAT64_PI / 4); // c = 1;
[ public ] Void Terminate(Void);
The SFXTrigonometric::Terminate function is automatically called by the destructor.
Copyright(c) 2002 - 2024 Sophia Cradle Incorporated All Rights Reserved. |