@@ -394,7 +394,7 @@ void RotatePointAroundVector( vec3_t dst, const vec3_t dir, const vec3_t point,
394
394
float sind, cosd, expr;
395
395
vec3_t dxp;
396
396
397
- degrees = DEG2RAD ( degrees );
397
+ degrees = Math::DegToRad ( degrees );
398
398
sind = sinf ( degrees );
399
399
cosd = cosf ( degrees );
400
400
expr = ( 1 - cosd ) * DotProduct ( dir, point );
@@ -452,7 +452,7 @@ void vectoangles( const vec3_t value1, vec3_t angles )
452
452
{
453
453
if ( value1[ 0 ] )
454
454
{
455
- yaw = RAD2DEG ( atan2f ( value1[ 1 ], value1[ 0 ] ) );
455
+ yaw = Math::RadToDeg ( atan2f ( value1[ 1 ], value1[ 0 ] ) );
456
456
}
457
457
458
458
else if ( value1[ 1 ] > 0 )
@@ -471,7 +471,7 @@ void vectoangles( const vec3_t value1, vec3_t angles )
471
471
}
472
472
473
473
forward = sqrtf ( value1[ 0 ] * value1[ 0 ] + value1[ 1 ] * value1[ 1 ] );
474
- pitch = RAD2DEG ( atan2f ( value1[ 2 ], forward ) );
474
+ pitch = Math::RadToDeg ( atan2f ( value1[ 2 ], forward ) );
475
475
476
476
if ( pitch < 0 )
477
477
{
@@ -705,7 +705,7 @@ float AngleBetweenVectors( const vec3_t a, const vec3_t b )
705
705
// this results in:
706
706
//
707
707
// angle = acos( (a * b) / (|a| * |b|) )
708
- return RAD2DEG ( acosf ( DotProduct ( a, b ) / ( alen * blen ) ) );
708
+ return Math::RadToDeg ( acosf ( DotProduct ( a, b ) / ( alen * blen ) ) );
709
709
}
710
710
711
711
// ============================================================
@@ -1011,15 +1011,15 @@ void AngleVectors( const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up
1011
1011
1012
1012
// static to help MS compiler fp bugs
1013
1013
1014
- angle = DEG2RAD ( angles[ YAW ] );
1014
+ angle = Math::DegToRad ( angles[ YAW ] );
1015
1015
sy = sinf ( angle );
1016
1016
cy = cosf ( angle );
1017
1017
1018
- angle = DEG2RAD ( angles[ PITCH ] );
1018
+ angle = Math::DegToRad ( angles[ PITCH ] );
1019
1019
sp = sinf ( angle );
1020
1020
cp = cosf ( angle );
1021
1021
1022
- angle = DEG2RAD ( angles[ ROLL ] );
1022
+ angle = Math::DegToRad ( angles[ ROLL ] );
1023
1023
sr = sinf ( angle );
1024
1024
cr = cosf ( angle );
1025
1025
@@ -1355,7 +1355,7 @@ void AxisToAngles( /*const*/ vec3_t axis[ 3 ], vec3_t angles )
1355
1355
{
1356
1356
if ( axis[ 0 ][ 0 ] )
1357
1357
{
1358
- yaw = RAD2DEG ( atan2f ( axis[ 0 ][ 1 ], axis[ 0 ][ 0 ] ) );
1358
+ yaw = Math::RadToDeg ( atan2f ( axis[ 0 ][ 1 ], axis[ 0 ][ 0 ] ) );
1359
1359
}
1360
1360
1361
1361
else if ( axis[ 0 ][ 1 ] > 0 )
@@ -1374,14 +1374,14 @@ void AxisToAngles( /*const*/ vec3_t axis[ 3 ], vec3_t angles )
1374
1374
}
1375
1375
1376
1376
length1 = sqrtf ( axis[ 0 ][ 0 ] * axis[ 0 ][ 0 ] + axis[ 0 ][ 1 ] * axis[ 0 ][ 1 ] );
1377
- pitch = RAD2DEG ( atan2f ( axis[ 0 ][ 2 ], length1 ) );
1377
+ pitch = Math::RadToDeg ( atan2f ( axis[ 0 ][ 2 ], length1 ) );
1378
1378
1379
1379
if ( pitch < 0 )
1380
1380
{
1381
1381
pitch += 360 ;
1382
1382
}
1383
1383
1384
- roll = RAD2DEG ( atan2f ( axis[ 1 ][ 2 ], axis[ 2 ][ 2 ] ) );
1384
+ roll = Math::RadToDeg ( atan2f ( axis[ 1 ][ 2 ], axis[ 2 ][ 2 ] ) );
1385
1385
1386
1386
if ( roll < 0 )
1387
1387
{
@@ -1577,7 +1577,7 @@ bool MatrixInverse( matrix_t matrix )
1577
1577
}
1578
1578
void MatrixSetupXRotation ( matrix_t m, vec_t degrees )
1579
1579
{
1580
- vec_t a = DEG2RAD ( degrees );
1580
+ vec_t a = Math::DegToRad ( degrees );
1581
1581
1582
1582
m[ 0 ] = 1 ;
1583
1583
m[ 4 ] = 0 ;
@@ -1598,7 +1598,7 @@ void MatrixSetupXRotation( matrix_t m, vec_t degrees )
1598
1598
}
1599
1599
void MatrixSetupYRotation ( matrix_t m, vec_t degrees )
1600
1600
{
1601
- vec_t a = DEG2RAD ( degrees );
1601
+ vec_t a = Math::DegToRad ( degrees );
1602
1602
1603
1603
m[ 0 ] = cosf ( a );
1604
1604
m[ 4 ] = 0 ;
@@ -1619,7 +1619,7 @@ void MatrixSetupYRotation( matrix_t m, vec_t degrees )
1619
1619
}
1620
1620
void MatrixSetupZRotation ( matrix_t m, vec_t degrees )
1621
1621
{
1622
- vec_t a = DEG2RAD ( degrees );
1622
+ vec_t a = Math::DegToRad ( degrees );
1623
1623
1624
1624
m[ 0 ] = cosf ( a );
1625
1625
m[ 4 ] = -sinf ( a );
@@ -1774,7 +1774,7 @@ void MatrixMultiplyRotation( matrix_t m, vec_t pitch, vec_t yaw, vec_t roll )
1774
1774
void MatrixMultiplyZRotation ( matrix_t m, vec_t degrees )
1775
1775
{
1776
1776
matrix_t tmp;
1777
- float angle = DEG2RAD ( degrees );
1777
+ float angle = Math::DegToRad ( degrees );
1778
1778
float s = sinf ( angle );
1779
1779
float c = cosf ( angle );
1780
1780
@@ -1857,15 +1857,15 @@ void MatrixToAngles( const matrix_t m, vec3_t angles )
1857
1857
1858
1858
if ( cp > 8192 * FLT_EPSILON )
1859
1859
{
1860
- angles[ PITCH ] = RAD2DEG ( theta );
1861
- angles[ YAW ] = RAD2DEG ( atan2f ( m[ 1 ], m[ 0 ] ) );
1862
- angles[ ROLL ] = RAD2DEG ( atan2f ( m[ 6 ], m[ 10 ] ) );
1860
+ angles[ PITCH ] = Math::RadToDeg ( theta );
1861
+ angles[ YAW ] = Math::RadToDeg ( atan2f ( m[ 1 ], m[ 0 ] ) );
1862
+ angles[ ROLL ] = Math::RadToDeg ( atan2f ( m[ 6 ], m[ 10 ] ) );
1863
1863
}
1864
1864
1865
1865
else
1866
1866
{
1867
- angles[ PITCH ] = RAD2DEG ( theta );
1868
- angles[ YAW ] = RAD2DEG ( -atan2f ( m[ 4 ], m[ 5 ] ) );
1867
+ angles[ PITCH ] = Math::RadToDeg ( theta );
1868
+ angles[ YAW ] = Math::RadToDeg ( -atan2f ( m[ 4 ], m[ 5 ] ) );
1869
1869
angles[ ROLL ] = 0 ;
1870
1870
}
1871
1871
@@ -1878,16 +1878,16 @@ void MatrixToAngles( const matrix_t m, vec3_t angles )
1878
1878
1879
1879
if ( fabsf( ca ) > 0.005f ) // Gimbal lock?
1880
1880
{
1881
- angles[ PITCH ] = RAD2DEG ( atan2f( m[ 6 ] / ca, m[ 10 ] / ca ) );
1882
- angles[ YAW ] = RAD2DEG ( a );
1883
- angles[ ROLL ] = RAD2DEG ( atan2f( m[ 1 ] / ca, m[ 0 ] / ca ) );
1881
+ angles[ PITCH ] = Math::RadToDeg ( atan2f( m[ 6 ] / ca, m[ 10 ] / ca ) );
1882
+ angles[ YAW ] = Math::RadToDeg ( a );
1883
+ angles[ ROLL ] = Math::RadToDeg ( atan2f( m[ 1 ] / ca, m[ 0 ] / ca ) );
1884
1884
}
1885
1885
1886
1886
else
1887
1887
{
1888
1888
// Gimbal lock has occurred
1889
- angles[ PITCH ] = RAD2DEG ( atan2f( -m[ 9 ], m[ 5 ] ) );
1890
- angles[ YAW ] = RAD2DEG ( a );
1889
+ angles[ PITCH ] = Math::RadToDeg ( atan2f( -m[ 9 ], m[ 5 ] ) );
1890
+ angles[ YAW ] = Math::RadToDeg ( a );
1891
1891
angles[ ROLL ] = 0;
1892
1892
}
1893
1893
@@ -1900,14 +1900,14 @@ void MatrixFromAngles( matrix_t m, vec_t pitch, vec_t yaw, vec_t roll )
1900
1900
static float sr, sp, sy, cr, cp, cy;
1901
1901
1902
1902
// static to help MS compiler fp bugs
1903
- sp = sinf ( DEG2RAD ( pitch ) );
1904
- cp = cosf ( DEG2RAD ( pitch ) );
1903
+ sp = sinf ( Math::DegToRad ( pitch ) );
1904
+ cp = cosf ( Math::DegToRad ( pitch ) );
1905
1905
1906
- sy = sinf ( DEG2RAD ( yaw ) );
1907
- cy = cosf ( DEG2RAD ( yaw ) );
1906
+ sy = sinf ( Math::DegToRad ( yaw ) );
1907
+ cy = cosf ( Math::DegToRad ( yaw ) );
1908
1908
1909
- sr = sinf ( DEG2RAD ( roll ) );
1910
- cr = cosf ( DEG2RAD ( roll ) );
1909
+ sr = sinf ( Math::DegToRad ( roll ) );
1910
+ cr = cosf ( Math::DegToRad ( roll ) );
1911
1911
1912
1912
m[ 0 ] = cp * cy;
1913
1913
m[ 4 ] = ( sr * sp * cy + cr * -sy );
@@ -2467,7 +2467,7 @@ void MatrixPerspectiveProjectionFovYAspectLH( matrix_t m, vec_t fov, vec_t aspec
2467
2467
{
2468
2468
vec_t width, height;
2469
2469
2470
- width = tanf ( DEG2RAD ( fov * 0 .5f ) );
2470
+ width = tanf ( Math::DegToRad ( fov * 0 .5f ) );
2471
2471
height = width / aspect;
2472
2472
2473
2473
m[ 0 ] = 1 / width;
@@ -2491,8 +2491,8 @@ void MatrixPerspectiveProjectionFovXYLH( matrix_t m, vec_t fovX, vec_t fovY, vec
2491
2491
{
2492
2492
vec_t width, height;
2493
2493
2494
- width = tanf ( DEG2RAD ( fovX * 0 .5f ) );
2495
- height = tanf ( DEG2RAD ( fovY * 0 .5f ) );
2494
+ width = tanf ( Math::DegToRad ( fovX * 0 .5f ) );
2495
+ height = tanf ( Math::DegToRad ( fovY * 0 .5f ) );
2496
2496
2497
2497
m[ 0 ] = 1 / width;
2498
2498
m[ 4 ] = 0 ;
@@ -2516,8 +2516,8 @@ void MatrixPerspectiveProjectionFovXYRH( matrix_t m, vec_t fovX, vec_t fovY, vec
2516
2516
{
2517
2517
vec_t width, height;
2518
2518
2519
- width = tanf ( DEG2RAD ( fovX * 0 .5f ) );
2520
- height = tanf ( DEG2RAD ( fovY * 0 .5f ) );
2519
+ width = tanf ( Math::DegToRad ( fovX * 0 .5f ) );
2520
+ height = tanf ( Math::DegToRad ( fovY * 0 .5f ) );
2521
2521
2522
2522
m[ 0 ] = 1 / width;
2523
2523
m[ 4 ] = 0 ;
@@ -2542,8 +2542,8 @@ void MatrixPerspectiveProjectionFovXYInfiniteRH( matrix_t m, vec_t fovX, vec_t f
2542
2542
{
2543
2543
vec_t width, height;
2544
2544
2545
- width = tanf ( DEG2RAD ( fovX * 0 .5f ) );
2546
- height = tanf ( DEG2RAD ( fovY * 0 .5f ) );
2545
+ width = tanf ( Math::DegToRad ( fovX * 0 .5f ) );
2546
+ height = tanf ( Math::DegToRad ( fovY * 0 .5f ) );
2547
2547
2548
2548
m[ 0 ] = 1 / width;
2549
2549
m[ 4 ] = 0 ;
@@ -2839,14 +2839,14 @@ void QuatFromAngles( quat_t q, vec_t pitch, vec_t yaw, vec_t roll )
2839
2839
static float sr, sp, sy, cr, cp, cy;
2840
2840
2841
2841
// static to help MS compiler fp bugs
2842
- sp = sinf(DEG2RAD (pitch) * 0.5);
2843
- cp = cosf(DEG2RAD (pitch) * 0.5);
2842
+ sp = sinf(Math::DegToRad (pitch) * 0.5);
2843
+ cp = cosf(Math::DegToRad (pitch) * 0.5);
2844
2844
2845
- sy = sinf(DEG2RAD (yaw) * 0.5);
2846
- cy = cosf(DEG2RAD (yaw) * 0.5);
2845
+ sy = sinf(Math::DegToRad (yaw) * 0.5);
2846
+ cy = cosf(Math::DegToRad (yaw) * 0.5);
2847
2847
2848
- sr = sinf(DEG2RAD (roll) * 0.5);
2849
- cr = cosf(DEG2RAD (roll) * 0.5);
2848
+ sr = sinf(Math::DegToRad (roll) * 0.5);
2849
+ cr = cosf(Math::DegToRad (roll) * 0.5);
2850
2850
2851
2851
q[0] = sr * cp * cy - cr * sp * sy; // x
2852
2852
q[1] = cr * sp * cy + sr * cp * sy; // y
@@ -3011,29 +3011,29 @@ void QuatToAngles( const quat_t q, vec3_t angles )
3011
3011
3012
3012
if ( test > 0.4995 )
3013
3013
{
3014
- angles[YAW] = RAD2DEG (-2 * atan2f (q[0 ], q[3 ]));
3014
+ angles[YAW] = Math::RadToDeg (-2 * atan2f (q[0 ], q[3 ]));
3015
3015
angles[PITCH] = 90 ;
3016
3016
angles[ROLL] = 0 ;
3017
3017
return ;
3018
3018
}
3019
3019
3020
3020
if ( test < -0.4995 )
3021
3021
{
3022
- angles[YAW] = RAD2DEG (2 * atan2f (q[0 ], q[3 ]));
3022
+ angles[YAW] = Math::RadToDeg (2 * atan2f (q[0 ], q[3 ]));
3023
3023
angles[PITCH] = -90 ;
3024
3024
angles[ROLL] = 0 ;
3025
3025
return ;
3026
3026
}
3027
3027
3028
3028
// original for normalized quaternions:
3029
- // angles[PITCH] = RAD2DEG (asinf( 2.0f * (q[3] * q[1] - q[2] * q[0])));
3030
- // angles[YAW] = RAD2DEG (atan2f(2.0f * (q[3] * q[2] + q[0] * q[1]), 1.0f - 2.0f * (q2[1] + q2[2])));
3031
- // angles[ROLL] = RAD2DEG (atan2f(2.0f * (q[3] * q[0] + q[1] * q[2]), 1.0f - 2.0f * (q2[0] + q2[1])));
3029
+ // angles[PITCH] = Math::RadToDeg (asinf( 2.0f * (q[3] * q[1] - q[2] * q[0])));
3030
+ // angles[YAW] = Math::RadToDeg (atan2f(2.0f * (q[3] * q[2] + q[0] * q[1]), 1.0f - 2.0f * (q2[1] + q2[2])));
3031
+ // angles[ROLL] = Math::RadToDeg (atan2f(2.0f * (q[3] * q[0] + q[1] * q[2]), 1.0f - 2.0f * (q2[0] + q2[1])));
3032
3032
3033
3033
// optimized to work with both normalized and unnormalized quaternions:
3034
- angles[PITCH] = RAD2DEG (asinf (2 .0f * test));
3035
- angles[YAW] = RAD2DEG (atan2f (2 .0f * (q[3 ] * q[2 ] + q[0 ] * q[1 ]), q2[0 ] - q2[1 ] - q2[2 ] + q2[3 ]));
3036
- angles[ROLL] = RAD2DEG (atan2f (2 .0f * (q[3 ] * q[0 ] + q[1 ] * q[2 ]), -q2[0 ] - q2[1 ] + q2[2 ] + q2[3 ]));
3034
+ angles[PITCH] = Math::RadToDeg (asinf (2 .0f * test));
3035
+ angles[YAW] = Math::RadToDeg (atan2f (2 .0f * (q[3 ] * q[2 ] + q[0 ] * q[1 ]), q2[0 ] - q2[1 ] - q2[2 ] + q2[3 ]));
3036
+ angles[ROLL] = Math::RadToDeg (atan2f (2 .0f * (q[3 ] * q[0 ] + q[1 ] * q[2 ]), -q2[0 ] - q2[1 ] + q2[2 ] + q2[3 ]));
3037
3037
}
3038
3038
3039
3039
void QuatMultiply ( const quat_t qa, const quat_t qb, quat_t qc )
0 commit comments