Changeset 453 for trunk


Ignore:
Timestamp:
07/30/15 20:49:02 (10 years ago)
Author:
epyon
Message:
  • added math/degrees and radians
  • added math/geometric - not used yet due to dual template parameters of vectors
Location:
trunk
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/nv/core/arcball.hh

    r451 r453  
    5050                        vec3 vb = get_arcball_vector( nposition );
    5151
    52                         m_angle = math::acos( glm::min( 1.0f, glm::dot( va, vb ) ) );
     52                        m_angle = math::acos( glm::min( 1.0f, math::dot( va, vb ) ) );
    5353                        m_axis  = glm::cross( va, vb );
    5454                        m_last  = nposition;
  • trunk/nv/interface/camera.hh

    r451 r453  
    3333                void set_perspective( f32 fov, f32 aspect, f32 near, f32 far )
    3434                {
    35                         m_projection = math::perspective( glm::radians( fov ), aspect, near, far );
     35                        m_projection = math::perspective( math::radians( fov ), aspect, near, far );
    3636                }
    3737                void set_ortho( f32 left, f32 right, f32 bottom, f32 top, f32 near = -1.0f, f32 far = 1.0f )
  • trunk/nv/stl/math.hh

    r451 r453  
    1313#include <nv/stl/math/common.hh>
    1414#include <nv/stl/math/constants.hh>
     15#include <nv/stl/math/geometric.hh>
    1516#include <nv/stl/math/matrix_transform.hh>
    1617#include <nv/stl/math/cast.hh>
  • trunk/nv/stl/math/common.hh

    r451 r453  
    1515
    1616#include <nv/common.hh>
     17#include <nv/stl/type_traits/common.hh>
    1718
    1819#if NV_COMPILER == NV_GNUC
     
    4445                using ::floor;
    4546                using ::ceil;
     47                using ::round;
    4648#if 0
    4749                template < typename T > using tvec2 = ::glm::detail::tvec2<T, glm::precision::highp>;
     
    6567                using glm::ctor;
    6668        }
     69
     70        template < typename T >
     71        struct is_math_vector : false_type {};
     72
     73        template < typename T >
     74        struct is_math_matrix : false_type {};
     75
     76        template < typename T >
     77        struct is_math_quat : false_type {};
     78
     79        template < typename T >
     80        struct is_math_class : bool_constant<
     81                is_math_vector< T >::value ||
     82                is_math_matrix< T >::value ||
     83                is_math_quat< T >::value
     84        > {};
     85
     86        template < typename T > struct is_math_vector< math::tvec2< T > > : true_type {};
     87        template < typename T > struct is_math_vector< math::tvec3< T > > : true_type {};
     88        template < typename T > struct is_math_vector< math::tvec4< T > > : true_type {};
     89        template < typename T > struct is_math_matrix< math::tmat2< T > > : true_type {};
     90        template < typename T > struct is_math_matrix< math::tmat3< T > > : true_type {};
     91        template < typename T > struct is_math_matrix< math::tmat4< T > > : true_type {};
     92        template < typename T > struct is_math_quat  < math::tquat< T > > : true_type {};
    6793
    6894        typedef math::tvec2<sint8> i8vec2;
  • trunk/nv/stl/math/constants.hh

    r451 r453  
    197197                }
    198198
     199                template < typename T >
     200                constexpr T radians( T degrees )
     201                {
     202                        static_assert( is_floating_point<T>::value, "Type expected to be floating point!" );
     203                        return degrees * static_cast<T>( 0.01745329251994329576923690768489 );
     204                }
     205
     206                template < typename T >
     207                constexpr T degrees( T radians )
     208                {
     209                        static_assert( is_floating_point<T>::value, "Type expected to be floating point!" );
     210                        return radians * static_cast<T>( 57.295779513082320876798154814105 );
     211                }
     212
    199213        }
    200214}
  • trunk/src/engine/particle_engine.cc

    r452 r453  
    749749                                        if ( edata.angle > 0.0f )
    750750                                        {
    751                                                 float emission_angle = glm::radians( edata.angle );
     751                                                float emission_angle = math::radians( edata.angle );
    752752                                                float cos_theta = r.frange( math::cos( emission_angle ), 1.0f );
    753753                                                float sin_theta = math::sqrt(1.0f - cos_theta * cos_theta );
  • trunk/src/rocket/rocket_interface.cc

    r395 r453  
    273273        nv::vertex_array m_va = m_context->create_vertex_array( rv, num_vertices, (unsigned*)indices, num_indices, nv::STATIC_DRAW );
    274274        //if ( info )   m_device->set_uniform( m_program, "texsize", nv::vec2( info->size ) );
    275         m_state.set_model( glm::translate( glm::mat4(), nv::vec3( translation.x, translation.y, 0.0f ) ) );
     275        m_state.set_model( nv::math::translate( nv::mat4(), nv::vec3( translation.x, translation.y, 0.0f ) ) );
    276276        m_context->draw( nv::TRIANGLES, m_rstate, m_state, m_program, m_va, num_indices );
    277277        m_context->release( m_va );
  • trunk/src/sdl/sdl_audio.cc

    r406 r453  
    7575                        if ( relative != vec3() )
    7676                        {
    77                                 angle = glm::degrees( -glm::orientedAngle( m_forward, glm::normalize( relative ), m_up ) );
     77                                angle = math::degrees( -glm::orientedAngle( m_forward, glm::normalize( relative ), m_up ) );
    7878                                distance = glm::clamp( 20.0f * glm::length( relative ), 0.0f, 255.0f );
    7979                        }
Note: See TracChangeset for help on using the changeset viewer.