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

// sin(x) = x - x^3/3! + x^5/5! - x^7/7! + ...
double sine(double radian)
{
	double result = radian;
	for (UINT64 n = 1; n < 9; n++)
	{
		result += (pow(radian, n * 2+1) / factorial(n * 2+1))*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.