Ignore:
Timestamp:
Feb 4, 2013, 10:24:20 PM (6 years ago)
Author:
sam
Message:

math: use "degrees" as the variable name for rotations for clarity.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/math/vector.cpp

    r2317 r2348  
    347347}
    348348
    349 template<> mat2 mat2::rotate(float angle)
    350 {
    351     angle *= (M_PI / 180.0f);
    352 
    353     float st = sin(angle);
    354     float ct = cos(angle);
     349template<> mat2 mat2::rotate(float degrees)
     350{
     351    degrees *= (M_PI / 180.0f);
     352
     353    float st = sin(degrees);
     354    float ct = cos(degrees);
    355355
    356356    mat2 ret;
     
    365365}
    366366
    367 template<> mat3 mat3::rotate(float angle, float x, float y, float z)
    368 {
    369     angle *= (M_PI / 180.0f);
    370 
    371     float st = sin(angle);
    372     float ct = cos(angle);
     367template<> mat3 mat3::rotate(float degrees, float x, float y, float z)
     368{
     369    degrees *= (M_PI / 180.0f);
     370
     371    float st = sin(degrees);
     372    float ct = cos(degrees);
    373373
    374374    float len = std::sqrt(x * x + y * y + z * z);
     
    399399}
    400400
    401 template<> mat3 mat3::rotate(float angle, vec3 v)
    402 {
    403     return rotate(angle, v.x, v.y, v.z);
     401template<> mat3 mat3::rotate(float degrees, vec3 v)
     402{
     403    return rotate(degrees, v.x, v.y, v.z);
    404404}
    405405
     
    484484}
    485485
    486 template<> quat quat::rotate(float angle, vec3 const &v)
    487 {
    488     angle *= (M_PI / 360.0f);
    489 
    490     vec3 tmp = normalize(v) * sin(angle);
    491 
    492     return quat(cos(angle), tmp.x, tmp.y, tmp.z);
    493 }
    494 
    495 template<> quat quat::rotate(float angle, float x, float y, float z)
    496 {
    497     return quat::rotate(angle, vec3(x, y, z));
     486template<> quat quat::rotate(float degrees, vec3 const &v)
     487{
     488    degrees *= (M_PI / 360.0f);
     489
     490    vec3 tmp = normalize(v) * sin(degrees);
     491
     492    return quat(cos(degrees), tmp.x, tmp.y, tmp.z);
     493}
     494
     495template<> quat quat::rotate(float degrees, float x, float y, float z)
     496{
     497    return quat::rotate(degrees, vec3(x, y, z));
    498498}
    499499
Note: See TracChangeset for help on using the changeset viewer.