#ifndef TRIG_HPP
// TRIG_HPP
#define TRIG_HPP
#include
#define DEPTH 8
namespace mt
{
const long double PI = 3.14159265358979323f;
// FACTORIAL
template struct fact
{
static const long long value = N * fact::value;
};
template struct fact
{
static const long long value = 1L;
};
// EXPONENTS
template struct power
{
static const long double value;
};
template const long double power::value
= X::value * power::value;
template struct power
{
static const long double value;
};
template const long double power::value = 1.0f;
// SIMPLIFY RADIAN TO INTERVAL [-2π, 2π]
template struct SimplifyRad
{
static const long double value;
};
template const long double SimplifyRad::value =
X::value - (2 * PI * (double) (int) (X::value/(2*PI))); // float modulo?
// COSINE
template struct cos
{
static const long double value;
};
template const long double cos::value =
(((N % 2 == 0 ? 1 : -1) * power::value) / ((long double)
fact::value)) + cos::value;
template struct cos
{
static const long double value;
};
template const long double cos::value = 1.0f;
// SINE
template struct sin
{
static const long double value;
};
template const long double sin::value =
(((N % 2 == 0 ? -1 : 1) * power::value) / ((long double)
fact::value)) + sin::value;
template struct sin
{
static const long double value;
};
template const long double sin::value = 0.0f;
// TANGENT
template struct tan
{
static const long double value;
};
template const long double tan::value = sin::value /
cos::value;
}
#endif
struct var
{
static const long double value;
};
const long double var::value = mt::PI / 4;
int main(int argc, char *argv[])
{
printf("%Lf\n", var::value);
printf("sin(%Lf) = %Lf\ncos(%Lf) = %Lf\ntan(%Lf) = %Lf\n",
var::value, mt::sin::value,
var::value, mt::cos::value,
var::value, mt::tan::value);
}
0.785398
sin(0.785398) = 0.707107
cos(0.785398) = 0.707107
tan(0.785398) = 1.000000
//Todd Veldhuizen
//
#define M_PI 3.141596
#include
#include
using namespace std;
// Compute J terms in the series expansion. K is the loop variable.
template
class SineSeries {
public:
enum { go = (K+1 != J) };
static inline float accumulate()
{
return 1-(I*2*M_PI/N)*(I*2*M_PI/N)/(2*K+2)/(2*K+3) *
SineSeries::accumulate();
}
};
// Specialization to terminate loop
template class SineSeries {
public:
static inline float accumulate()
{ return 1; }
};
template
class Sine {
public:
static inline float sin()
{
return (I*2*M_PI/N) * SineSeries::accumulate();
}
};
int main()
{
float f = Sine::sin();
cout ................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related searches
- right angle trig calculator online
- 6 trig functions calculator triangle
- 6 trig functions calculator
- online calculator with trig functions
- solve the triangle trig calculator
- inverse trig calculator in radians
- online trig calculator in degrees
- calculator for trig functions
- trig calculator sin cos tan
- inverse trig calculator
- trig calculator degrees
- trig calculator sec