/*****************************************************************************
 * $LastChangedDate: 2010-10-23 18:22:39 -0400 (Sat, 23 Oct 2010) $
 * @file
 * @author  Jim E. Brooks  http://www.palomino3d.org
 * @brief   OSG-specific math functions.
 * REMINDERS: Consider using MATH_EXCEPTION() instead of ASSERT().
 *//*
 * LEGAL:   COPYRIGHT (C) 2009 JIM E. BROOKS
 *          THIS SOURCE CODE IS RELEASED UNDER THE TERMS
 *          OF THE GNU GENERAL PUBLIC LICENSE VERSION 2 (GPL 2).
 *****************************************************************************/

#ifndef MATH_FUNCS_OSG_HH
#define MATH_FUNCS_OSG_HH 1

#include "math/funcs_debug.hh"

namespace math {

/*****************************************************************************
 * Convert an axis index to a 3D vector.
 * Useful for then passing 3D vector to OSG makeRotate() etc.
 * @param   axis
 *          XX,YY,ZZ
 * @param   dir
 *          -1,1
 *****************************************************************************/
INLINE osg::Vec3f
Axis2Vec3( const uint axis, const int dir )  // variant Axis2Vec3() without dir arg exists
{
ASSERT_AXIS3( axis );
ASSERT( ABS(dir) == 1 );

    const fp one = 1.0f * dir;
    switch ( axis )
    {
        case XX: return osg::Vec3f( one,  0.0f, 0.0f ); break;
        case YY: return osg::Vec3f( 0.0f, one,  0.0f ); break;
        case ZZ: return osg::Vec3f( 0.0f, 0.0f, one  ); break;
    }
    ASSERT(false); return osg::Vec3f(0,0,0);   // oops
}

// Without dir arg.
INLINE osg::Vec3f
Axis2Vec3( const uint axis )
{
ASSERT_AXIS3( axis );

    switch ( axis )
    {
        case XX: return osg::Vec3f( 1.0f, 0.0f, 0.0f ); break;
        case YY: return osg::Vec3f( 0.0f, 1.0f, 0.0f ); break;
        case ZZ: return osg::Vec3f( 0.0f, 0.0f, 1.0f ); break;
    }
    ASSERT(false); return osg::Vec3f(0,0,0);   // oops
}

} // namespace math

#endif // MATH_FUNCS_OSG_HH
