mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-14 10:05:44 -04:00
Remove Math_FastTan
Despite the name, it's not even fast at all. And it's only used from one place where replacing with a simple sin(x) / cos(x) will do anyways.
This commit is contained in:
parent
0053d2245d
commit
b62a78765d
@ -72,18 +72,6 @@ bool Math_IsPowOf2(int value) {
|
||||
return value != 0 && (value & (value - 1)) == 0;
|
||||
}
|
||||
|
||||
/* Not the most precise Tan(x), but within 10^-15 of answer, so good enough for here */
|
||||
double Math_FastTan(double angle) {
|
||||
double cosA = Math_Cos(angle), sinA = Math_Sin(angle);
|
||||
int sign;
|
||||
if (cosA < -0.00000001 || cosA > 0.00000001) return sinA / cosA;
|
||||
|
||||
/* tan line is parallel to y axis, infinite gradient */
|
||||
sign = Math_Sign(sinA);
|
||||
if (cosA) sign *= Math_Sign(cosA);
|
||||
return sign * MATH_POS_INF;
|
||||
}
|
||||
|
||||
double Math_FastLog(double x) {
|
||||
/* x = 2^exp * mantissa */
|
||||
/* so log(x) = log(2^exp) + log(mantissa) */
|
||||
|
@ -31,7 +31,6 @@ double Math_Log(double x);
|
||||
/* Computes e^x. Can also be used to approximate y^x. */
|
||||
/* e.g. for 3^x, use: Math_Exp(log(3)*x) */
|
||||
double Math_Exp(double x);
|
||||
double Math_FastTan(double x);
|
||||
|
||||
int Math_Floor(float value);
|
||||
int Math_Ceil(float value);
|
||||
|
@ -183,8 +183,9 @@ void Matrix_OrthographicOffCenter(struct Matrix* result, float left, float right
|
||||
result->Row3.Z = -(zFar + zNear) / (zFar - zNear);
|
||||
}
|
||||
|
||||
static double Tan_Simple(double x) { return Math_Sin(x) / Math_Cos(x); }
|
||||
void Matrix_PerspectiveFieldOfView(struct Matrix* result, float fovy, float aspect, float zNear, float zFar) {
|
||||
float c = zNear * (float)Math_FastTan(0.5f * fovy);
|
||||
float c = zNear * (float)Tan_Simple(0.5f * fovy);
|
||||
Matrix_PerspectiveOffCenter(result, -c * aspect, c * aspect, -c, c, zNear, zFar);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user