I searched math library for OpenGL, but I couldn't find suitable library for me ( has bug, doesn't have 4 dimention vector, matrix component order is not compatible OpenGL ). This is a GLSL like math library. NVSDK and ATI SDK provide math library. And these library have same name classes, for example vec2, vec3, vec4, mat2, mat3, mat4 ... these name is same in GLSL. So I thought "If I use these name's math library, I can write more portable software". So I make this library. Some functions in GLSL have not been implemented yet. In the future, I want to impletemnt.
usage Usage
#include <gslib/glsl_math/glsl_math.h> using namespace gslib::glsl_math; vec2 a( 1, 2 ); vec2 b( 2, 3 ); vec2 c = a + b; // = ( 3, 5 ) vec2 d = a * b; // = ( 2, 6 ) // column major ( same as GLSL ) mat2 m( 1, 3, // 1 2 2, 4 ); // 3 4 vec2 e = m * a; // = ( 7, 10 ) right hand system ( OpenGL ) vec2 f = a * m; // = ( 5, 11 ) left hand system ( DirectX ) vec4 v4( 1, 2, 3, 4 ); vec2& v4_xy = v4.xy(); // = ( 1, 2 ) simplified swizzle function. return reference vec2& v4_zw = v4.zw(); // swizzle function is only continuous combination. xy, yz, zw are ok! but xz yx xx don't exist. // rotate 90 around z axis quat q( vec3( 0, 0, 1 ), radians( 90 ) ); quat x( 1, 0, 0, 0 ); quat y = q * x * conj( q ); // = ( 0, 1, 0, 0 )
This library depends boost library.
Copyright (C) 2004 &o
This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: