#ifndef MATH3D_H
#define MATH3D_H
/*============================================================================
    ORCA Interpreter
    Copyright (C) 2005-2006  Karl Robillard

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
===========================================================================*/


#ifdef __cplusplus
extern "C" {
#endif


#define OR_PI           3.14159265358979323846
#define degToRad(deg)   ((OR_PI/180.0)*(double)(deg))
#define radToDeg(rad)   ((180.0/OR_PI)*(double)(rad))


/* Matrix functions */

void orLoadIdentity( float* );
void orLoadRotation( float* mat, const float* axis, float radians );
void orMatrixMult( const float* a, const float* b, float* result );
void orTransLocal( float* mat, float x, float y, float z );
void orMatrixTranspose( float* mat, const float* a );
void orMatrixInverse( float* mat, const float* a );


/* Vector functions */

float orDistance( const float* vecA, const float* vecB );
void  orTransform( float* pnt, const float* mat );
void  orTransform3x3( float* pnt, const float* mat );
void  orReflect( const float* a, const float* b, float* result );
void  orNormalize( float* vec );

#define orDot(a,b)  ((a[0] * b[0]) + (a[1] * b[1]) + (a[2] * b[2]))

#define orCross(a,b,res) \
    res[0] = (a[1] * b[2]) - (a[2] * b[1]); \
    res[1] = (a[2] * b[0]) - (a[0] * b[2]); \
    res[2] = (a[0] * b[1]) - (a[1] * b[0])


/* ORCA integration functions */

int  orLoadVectorBlock( float*, int count, OValue* blkV );


#ifdef __cplusplus
}
#endif


#endif  /* MATH3D_H */
