{I+=codeWee;}
[C++] Math: Calculating cosine value by using Taylor Expansion
UINT64 factorial(UINT64 n)
{
	if (n == 1)
		return 1;
	return n*factorial(n - 1);
}

// cos(x) = 1 - x^2/2! + x^4/4! - x^6/6! + ...
double cosine(double radian)
{
	double result = 1;
	for (UINT64 n = 1; n < 9; n++) 
	{
		result += (pow(radian, n * 2) / factorial(n * 2))*pow(-1,n);
	}
	return result;
}
HTML | PHP | C++ | DirectX11 | Javascript | C# | HTML5 | ASP | SQL | General | CSS | Oculus Rift | Unity3d | Virtools SDK | Tip | NSIS | PowerShell | node.js | Web API | RTSP | All
Copyright© 2016 CodeWee.com All rights reserved.