Skip to content

Instantly share code, notes, and snippets.

@kevinmoran
kevinmoran / cubicSinf.h
Created October 9, 2019 15:49
Cubic approximation of sinf(), if you only need something sinusoid-ish
// Source: https://www.youtube.com/watch?v=1xlCVBIF_ig
float cubicSinf(float x)
{
float t = x * 0.15915f;
t = t - (int)t;
return 20.785f * t * (t - 0.5f) * (t - 1.f);
}
@kevinmoran
kevinmoran / SinApprox.h
Last active October 9, 2019 15:50
Sin Approximation
// From: https://web.archive.org/web/20080228213915/http://www.devmaster.net/forums/showthread.php?t=5784
float sinApprox(float x)
{
const float kPI32 = 3.14159265359f;
const float B = 4/kPI32;
const float C = -4/(kPI32*kPI32);
float y = B * x + C * x * abs(x);
@kevinmoran
kevinmoran / noacos_derivation.md
Last active January 2, 2024 09:49
How to Calculate a Rotation Matrix to Align Vector A to Vector B in 3D